home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / CPPSTYLE.ARJ / STYLE.THD
Text File  |  1991-08-20  |  112KB  |  2,950 lines

  1.  
  2. #: 33394 S5/C++ Study Group            orig=ROOT next= 28  prev=
  3.     09-Aug-91  20:29:41                 No: 1 Replies 4
  4. Sb: #C++ Programming Style
  5. Fm: Brian Richter 76437,736
  6. To: All
  7.    
  8. Hello again.
  9.    
  10. In a completely different thread, I was talking about what would constitute
  11. good or perhaps "accepted" C++ style, as opposed to just being correct.  I'm
  12. sure there are many such issues that are not explicitly defined but for which
  13. people generally come up with similar answers.  So I thought that perhaps it
  14. would be an interesting topic for discussion.
  15.    
  16. Here's an example of what I'm talking about.  This is something that I haven't
  17. specifically seen elsewhere, but I just started doing this way. Suppose I have
  18. a light switch.  I can either turn the switch on or off, or I might just want
  19. to look at the switch to examine its state.  So to examine the "toggle" state
  20. of the switch, I tend to do it like this:
  21.    
  22.   class LightSwitch
  23.   {
  24.     ...
  25.     void toggle(bool b);       // Sets state of toggle
  26.     bool toggle();             // Returns current state of toggle
  27.   }
  28.    
  29. As an extension to this, a neat idea might be to have the "set" function return
  30. the previous state of the toggle; that saves a step when you want to set it and
  31. later return it to whatever state it was previously, though it may look more
  32. confusing in the code.  But it wouldn't look confusing if it were common
  33. practice...
  34.    
  35.                                        Brian
  36.    
  37.    
  38.    
  39. #: 33398 S5/C++ Study Group            orig=PgUp next= 5   prev=
  40.     09-Aug-91  22:09:14                 No: 2 One Reply
  41. Sb: #33394-#C++ Programming Style
  42. Fm: Mark Betz [GAMERS] 76605,2346
  43. To: Brian Richter 76437,736
  44.    
  45. I don't know, Brian. On the first pass your reasons for wanting ::toggle() to
  46. return the previous state make sense. But the more I think about it the more it
  47. seems like muddying the waters for little gain, especially if the code is
  48. inlined, which in this case it probably would be. I guess the bottom line is a
  49. design question: how often will you need to set, then restore, the state of the
  50. lightswitch?
  51.    
  52. I think the whole question of C++ style is problematic. Certain styles
  53. perpetuate themselves. For instance, I've learned almost everything I know
  54. about C++ (maybe 10% of what there is to know <g>) from the people here, and
  55. the BI manuals. So whatever mix of those styles becomes familiar to me is
  56. probably the one I'll be stuck with.
  57.    
  58.    
  59.                                                        --Mark
  60.    
  61.    
  62.    
  63.    
  64. #: 33406 S5/C++ Study Group            orig=PgUp next=     prev=
  65.     09-Aug-91  23:36:32                 No: 3 One Reply
  66. Sb: #33398-C++ Programming Style
  67. Fm: Greg Comeau (ComeauComp) 72331,3421
  68. To: Mark Betz [GAMERS] 76605,2346
  69.    
  70. That toggle could be incline and return a value should not inherently disturb
  71. anything.
  72.  
  73.  
  74.  
  75.  
  76. #: 33436 S5/C++ Study Group            orig=PgUp next=     prev=
  77.     10-Aug-91  16:13:50                 No: 4
  78. Sb: #33406-C++ Programming Style
  79. Fm: Mark Betz [GAMERS] 76605,2346
  80. To: Greg Comeau (ComeauComp) 72331,3421
  81.    
  82. I agree, Greg. But the question boils down to whether or not it's worth it
  83. to duplicate the get-switch-state activity. That function was already
  84. provided through a get-state method. Brian's idea was to add functionality
  85. to the set-switch-state activity which would return the previous switch
  86. state before toggling it. So the difference between the two methods is this:
  87.    
  88.        store_state = lightswitch.get_state();
  89.        lightswitch.set_state(new_state);
  90.    
  91. or
  92.    
  93.        store_state = lightswitch.set_state(new_state);
  94.    
  95. My point was that this is a bit less comprehensible, and probably doesn't
  96. gain you much of anything if the code is inlined (which it probably would be
  97. in this simple example).
  98.    
  99.                                                       --Mark
  100.  
  101.  
  102. #: 33405 S5/C++ Study Group            orig= 1   next= 8   prev= 2
  103.     09-Aug-91  23:36:29                 No: 5 One Reply
  104. Sb: #33394-C++ Programming Style
  105. Fm: Greg Comeau (ComeauComp) 72331,3421
  106. To: Brian Richter 76437,736
  107.    
  108. I don't think I have any problem with your considering the return of the
  109. previous state when setting the new one (such a thing is a common idiom) but I
  110. don't think that I agree with that the bool one should have the same name.
  111.  
  112.  
  113.  
  114.  
  115. #: 33424 S5/C++ Study Group            orig=PgUp next=     prev=
  116.     10-Aug-91  14:17:16                 No: 6 One Reply
  117. Sb: #33405-C++ Programming Style
  118. Fm: Brian Richter 76437,736
  119. To: Greg Comeau (ComeauComp) 72331,3421
  120.    
  121. Do you mean that there should be a "set_toggle" and a "get_toggle" or something
  122. like that?
  123.    
  124. I think the first time I saw things return the previous state when you set a
  125. new one was in some of the Windows API functions.  Now that I think of it, if
  126. you return the previous value, there's another consistent way to think of these
  127. functions.  The way I originally thought of them was as two functions that
  128. happen to have the same name, one to set a value and one to get a value.  But
  129. they could be thought of as two forms of one function.  This one function
  130. always returns the current value, and has an optional argument of a new value
  131. that you want to set.  I don't know how intuitive that would seem in an actual
  132. program, but it seems like an interesting idea...
  133.    
  134.                                        Brian
  135.  
  136.  
  137. #: 33455 S5/C++ Study Group            orig=PgUp next=     prev=
  138.     10-Aug-91  23:15:50                 No: 7
  139. Sb: #33424-C++ Programming Style
  140. Fm: Greg Comeau (ComeauComp) 72331,3421
  141. To: Brian Richter 76437,736
  142.    
  143. Yes, I meant something connotative along the lines of get/set.
  144.    
  145. It is a common idion that set routines and return (pre-get) the old value. I
  146. don't think this get'ing nature should allow them to have the same names
  147. though.
  148.  
  149.  
  150.  
  151. #: 33409 S5/C++ Study Group            orig= 1   next= 26  prev= 5
  152.     10-Aug-91  00:44:41                 No: 8 Replies 2
  153. Sb: #33394-C++ Programming Style
  154. Fm: John M. Dlugosz 70007,4657
  155. To: Brian Richter 76437,736
  156.    
  157. Well, first I see that you used InitialCaps in the class name, and used a
  158. `bool' type, and formatted your code a certain way, and added comments.  that
  159. is all style.  It could have been much different.
  160.    
  161. Here is some conventions from my stuff:
  162.    
  163.    class whatever {
  164.       rect Area;
  165.    public:
  166.       const rect& area() const {return Area;}
  167.       void area (const rect& a) { Area= a; }
  168.       //....
  169.    
  170. that is, have access members in lower case, and private memebrs with the same
  171. name in initial caps.  Have both test and set members with the same name.  Use
  172. const in all the right places (many people forget this).
  173.    
  174. --John
  175.  
  176.  
  177.  
  178. #: 33425 S5/C++ Study Group            orig=PgUp next= 18  prev=
  179.     10-Aug-91  14:17:23                 No: 9 Replies 2
  180. Sb: #33409-C++ Programming Style
  181. Fm: Brian Richter 76437,736
  182. To: John M. Dlugosz 70007,4657
  183.    
  184. Yes, lots of those little things that one tends to take for granted are really
  185. important elements of style.
  186.    
  187. As I look at your example I realize that my example could have used at least
  188. one "const".  Being previously a C programmer I still tend to forget to include
  189. "const" at times.  In fact, sometimes I'll just go through my classes and make
  190. sure all the "const"s are where they should be.  I usually find a couple
  191. missing.
  192.    
  193. I like the idea of private members and access functions having the same name;
  194. it sort of links them together.  Although lately I seem to have converted over
  195. to Hungarian notation.  Perhaps some would even say I've taken it to extremes. 
  196. In the last project I actually invented a different little Hungarian
  197. abbreviation for every class.  And I added a couple of abbreviations for
  198. private members, arrays, and constants (which was tricky because I ran out of
  199. letters).  So I might have something like this:
  200.    
  201.   class LightSwitch
  202.   {
  203.     bool zbToggle;     // 'z' is for private member
  204.     char zqcText[4];   // 'q' is for array
  205.   public:
  206.     bool toggle() const { return zbToggle; }
  207.     void toggle(bool b) { zbToggle = b; }
  208.   }
  209.    
  210.                                        Brian
  211.  
  212.  
  213.  
  214. #: 33442 S5/C++ Study Group            orig=PgUp next= 12  prev=
  215.     10-Aug-91  19:12:31                 No: 10 One Reply
  216. Sb: #33425-C++ Programming Style
  217. Fm: John M. Dlugosz 70007,4657
  218. To: Brian Richter 76437,736
  219.    
  220. Once you add a missing `const' they tend to avalanche.
  221.    
  222. same name:  a while back we went through several major classes in the library
  223. and decided on naming and style conventions.  Hopefully our dabbling in it
  224. before led us to a good solution.  IAC, _having_ a convention is the most
  225. important part.
  226.    
  227. We are also very carefull to have uniform use of parameters.  That is,
  228. functions tend to take the same things in the same order.  And functions in
  229. different classes tend to have the same name.  That makes it easy to keep track
  230. of things.  Instead of many hundreds of functions in C, you have a few
  231. "methods" to remember.  Also variations on a functions will be overloaded
  232. forms.  Like drawing a rectangle with 4 ints, two points, or a rect.  3
  233. functions, one name to remember.
  234.    
  235. I don't like the hungarian notation.  C++ is typesafe enough, with tools like
  236. implicit conversion and overloading, it is counterproductive. I don't have to
  237. know that carefully what type I'm dealing with, since the call makes sence in
  238. any case.
  239.    
  240. --John
  241.  
  242.  
  243.  
  244. #: 33487 S5/C++ Study Group            orig=PgUp next=     prev=
  245.     11-Aug-91  21:44:40                 No: 11
  246. Sb: #33442-C++ Programming Style
  247. Fm: Brian Richter 76437,736
  248. To: John M. Dlugosz 70007,4657
  249.    
  250. I agree that having a naming/style convention is very important.  The things
  251. you mention sound like they make sense, too.  I think that the methods in a
  252. class ought to be so consistent and intuitive that you never have to look at a
  253. reference manual or the include file to remember how to do what you want.
  254.    
  255. Way back in '85 I first started learning about Windows, and I also got a lot of
  256. hints on style from that, including Hungarian notation.  Recently I found it to
  257. be a lifesaver in a 25,000 line C program.
  258.    
  259. But C++ is perhaps a different story.  Sometimes I'm guilty of some of the
  260. common mistakes of C programmers moving to C++ (i.e., using pointers for what
  261. really should be references, forgetting 'const', etc.) and since Hungarian
  262. notation helped me in C I naturally carried it into C++.  I still don't quite
  263. "think in C++" completely.  C++ is definitely more typesafe in some ways than
  264. C, and as you say, because of implicit conversion and overloading a decent set
  265. of methods will work with whatever reasonable type of data you give it.  I need
  266. a couple of days to think about it, and then I'll throw together a list of
  267. "what Hungarian notation does for me" which might make an interesting topic of
  268. discussion...
  269.    
  270.                                        Brian
  271.  
  272.  
  273.  
  274. #: 33520 S5/C++ Study Group            orig= 9   next=     prev= 10
  275.     12-Aug-91  22:04:42                 No: 12 Replies 3
  276. Sb: #33425-C++ Programming Style
  277. Fm: Greg Comeau (ComeauComp) 72331,3421
  278. To: Brian Richter 76437,736
  279.    
  280. >lately I seem to have converted over to Hungarian notation
  281.    
  282. There was gem'ish thread I had with Charles Petzold about a year ago in another
  283. forum with Charles favoring H.h. and me not.  I wished that I had saved it. In
  284. any event, my perspective is that Hungarian breaks down real quickly. This is
  285. not to say tangents off of the essence of it aren't usable, but and and of
  286. itself, and in general, I just cannot make it practical for my own code.
  287.  
  288.  
  289.  
  290. #: 33526 S5/C++ Study Group            orig=PgUp next= 16  prev=
  291.     13-Aug-91  00:20:25                 No: 13 Replies 2
  292. Sb: #33520-#C++ Programming Style
  293. Fm: John M. Dlugosz 70007,4657
  294. To: Greg Comeau (ComeauComp) 72331,3421
  295.    
  296. I beleive that the hungarian notation and other things like it go against the
  297. abilities of C++.  I think that useing overloading and uniform naming goes much
  298. farther.
  299.    
  300. --John
  301.    
  302.  
  303.  
  304. #: 33536 S5/C++ Study Group            orig=PgUp next=PgDn prev=
  305.     13-Aug-91  04:58:39                 No: 14
  306. Sb: #33526-C++ Programming Style
  307. Fm: Don E. Groves, Jr. 71310,3702
  308. To: John M. Dlugosz 70007,4657
  309.    
  310. John,
  311. < I beleive that the hungarian notation and other things like it go
  312. < against the abilities of C++.  I think that useing overloading and
  313. < uniform naming goes much farther.
  314.    
  315.    I agree 100% with you.
  316.    
  317.   I've always seen "hungarian notation" as a way to bring C++ Type-Safe Linkage
  318. to PRE-C++ compilers'.
  319.   C++ for the most part does away with any need for h.n.
  320.   IMHO  "hungarian notation" works against C++ Overloading.
  321. Jr..
  322.  
  323.  
  324.  
  325. #: 33545 S5/C++ Study Group            orig= 13  next=     prev=PgUp
  326.     13-Aug-91  11:48:48                 No: 15
  327. Sb: #33526-C++ Programming Style
  328. Fm: Brian Richter 76437,736
  329. To: John M. Dlugosz 70007,4657
  330.    
  331. I did convert to HN before C++, so that could very well be true.  Without HN,
  332. it seems that some sort of conventions in naming would help.  I developed some
  333. on my own but I'm not sure that they're necessarily good or that other people
  334. would like or understand them.  Among the things I came up with that might need
  335. to be distinguished are:
  336.    
  337.        constants as opposed to variables or #defines
  338.        values for enumerated types
  339.        class names and type names
  340.        class members
  341.    
  342. I've been writing class names LikeThis and using some form of Hungarian naming
  343. for the others.  Constants start with a "k".  For lack of thinking of something
  344. better, enumerated values have a prefix, an underscore, and then the name of
  345. the value.  Something without the underscore would refer to a variable of that
  346. enumerated type.  Class members got a "z" because I couldn't think of any other
  347. letter I wasn't already using.
  348.    
  349. Also, there are the obvious things such as distinguishing between ints and
  350. longs, signed and unsigned, pointers and arrays.  These are cases where HN has
  351. probably saved me from getting confused.  Although I'd expect the usual
  352. counterargument (I'm sure someone reading this is at least *thinking* it) that
  353. if your program is designed "properly" you won't get confused anyway...
  354.    
  355.                                        Brian
  356.  
  357.  
  358.  
  359. #: 33544 S5/C++ Study Group            orig= 12  next=PgDn prev= 13
  360.     13-Aug-91  11:48:41                 No: 16
  361. Sb: #33520-C++ Programming Style
  362. Fm: Brian Richter 76437,736
  363. To: Greg Comeau (ComeauComp) 72331,3421
  364.    
  365. Sounds like it would have been an interesting thread.  In what sense would you
  366. say Hungarian notation breaks down?  Just that it loses its usefulness, or does
  367. it actually cause some problems or confusion?
  368.    
  369.                                        Brian
  370.  
  371.  
  372.  
  373. #: 33692 S5/C++ Study Group            orig= 12  next=     prev=PgUp
  374.     16-Aug-91  10:56:39                 No: 17
  375. Sb: #33520-C++ Programming Style
  376. Fm: David Michmerhuizen 70322,617
  377. To: Greg Comeau (ComeauComp) 72331,3421 (X)
  378.    
  379. absolutly. I think hungarian makes it harder to read code and concentrate on
  380. it's meaning, because it makes it harder to *actually read the code*, ie, say
  381. the words in your mind.  As you read along you have to filter out all those
  382. little prefixes. yuk.
  383.  
  384.  
  385.  
  386. #: 33519 S5/C++ Study Group            orig= 8   next=     prev= 9
  387.     12-Aug-91  22:04:36                 No: 18 One Reply
  388. Sb: #33409-C++ Programming Style
  389. Fm: Greg Comeau (ComeauComp) 72331,3421
  390. To: John M. Dlugosz 70007,4657
  391.    
  392. >Have both test and set members with the same name.
  393.    
  394. Why?
  395.    
  396. Also, if/when possible, this could be a candidate for default arguments.
  397.  
  398.  
  399.  
  400. #: 33527 S5/C++ Study Group            orig=PgUp next=     prev=
  401.     13-Aug-91  00:20:33                 No: 19 One Reply
  402. Sb: #33519-#C++ Programming Style
  403. Fm: John M. Dlugosz 70007,4657
  404. To: Greg Comeau (ComeauComp) 72331,3421
  405.    
  406. <<why>> well, it just felt right.  After a hodge podge of classes, we decided
  407. to see what we liked and rewrite to a more standard style. Common names was one
  408. main issue.  One name to remember.  I guess a schema of set_xxx and test_xxx
  409. would be just as easy, but it splits them up in the documentation.  I organized
  410. around a common header for a group of overloaded functions followed by the
  411. declarations of the various forms. It makes for a nice manual, thus far.
  412.    
  413. I'm not sure of your point.  That this would prevent the set member from having
  414. a default argument?  I've not seen many defaults there actually. If you knew
  415. what you were setting it to, why bother <g>?
  416.    
  417. On the same thread, I've used functons that set and return the old value. I'm
  418. not sure if _I_ like it, but some users seem to.  As long as it is inline, it
  419. does not waste anything.  It also seems that there are times when that is handy
  420. and other times when 2 lines would be clearer.
  421.    
  422. Also, some set members set values and flags, or sets of related values. For
  423. example, setting a fill pattern (2 parameters, the second of which can default)
  424. also sets the flag to enable fill patterns.  So set methods can be handier than
  425. just assignments to public members.
  426.    
  427. --John
  428.    
  429.  
  430. #: 33546 S5/C++ Study Group            orig=PgUp next=     prev=
  431.     13-Aug-91  11:48:52                 No: 20 One Reply
  432. Sb: #33527-C++ Programming Style
  433. Fm: Brian Richter 76437,736
  434. To: John M. Dlugosz 70007,4657
  435.    
  436. My intuition also tells me that it's easier to have "set" and "get" functions
  437. with the same name.  There's no ambiguity because it's easy to see if there are
  438. any arguments, and there are less names to remember...
  439.    
  440.                                        Brian
  441.  
  442.  
  443.  
  444. #: 33563 S5/C++ Study Group            orig=PgUp next=     prev=
  445.     13-Aug-91  18:01:13                 No: 21 One Reply
  446. Sb: #33546-C++ Programming Style
  447. Fm: John M. Dlugosz 70007,4657
  448. To: Brian Richter 76437,736
  449.    
  450. <<less names to remember>>  That not only works across the stuff you know, but
  451. should let you extrapolate.  On seeing a functoin name in a strange class, you
  452. should say "of cource!".  And have no trouble ever remembering it.
  453.    
  454. I've got lots of classes with a width() member.  Width of a rectangle, a
  455. viewport, the image of a string, a bitmap, etc.  That is just the old promice
  456. of Object Oriented Programming-- the thing understands its message. It _ought_
  457. to have the same name.
  458.    
  459. --John
  460.  
  461.  
  462.  
  463. #: 33584 S5/C++ Study Group            orig=PgUp next=     prev=
  464.     14-Aug-91  11:50:52                 No: 22 One Reply
  465. Sb: #33563-C++ Programming Style
  466. Fm: Brian Richter 76437,736
  467. To: John M. Dlugosz 70007,4657
  468.    
  469. Yes, I think you should be able to extrapolate!  Ideally, it would be nice to
  470. be able to just pull in a class and immediately be able to use it, just by
  471. doing whatever seems logical, without looking at the include file or cracking
  472. open a reference manual.  I guess we're not quite at that level of
  473. standardization yet, but that definitely is the promise of OOP.
  474.    
  475. That's one thing that sometimes concerns me about using other people's
  476. libraries.  Suppose I use the library and somehow it doesn't quite do what I
  477. want.  The cost of buying another library to use is small compared to the
  478. effort of changing my program to conform with the other library's conventions. 
  479. If there were some standard ways that things were usually done, I could easily
  480. switch libraries in situations like this.  Knowing I could switch, I would be
  481. less reluctant to use these libraries.
  482.    
  483.                                        Brian
  484.  
  485.  
  486.  
  487. #: 33591 S5/C++ Study Group            orig=PgUp next=     prev=
  488.     14-Aug-91  15:51:00                 No: 23 One Reply
  489. Sb: #33584-C++ Programming Style
  490. Fm: John M. Dlugosz 70007,4657
  491. To: Brian Richter 76437,736
  492.    
  493. Yes, style across multiple libraries is another story.  But internal
  494. consistancy is the first step.
  495.    
  496. <<Suppose I use the library and somehow it doesn't quite do what I want.>> I
  497. beleive in source code!
  498.    
  499. --John
  500.  
  501.  
  502.  
  503. #: 33648 S5/C++ Study Group            orig=PgUp next=     prev=
  504.     15-Aug-91  11:58:56                 No: 24 One Reply
  505. Sb: #33591-C++ Programming Style
  506. Fm: Brian Richter 76437,736
  507. To: John M. Dlugosz 70007,4657
  508.    
  509. I already have the next three stages of the conversation, I think.
  510.    
  511. 1. Yes, source code is good to have, so that you can modify a library if it
  512. doesn't quite do what you want.
  513.    
  514. 2. But then you have to try to learn and understand all the code if you ever
  515. want to change it.
  516.    
  517. 3. Yes, but is it easier to learn someone else's code or to rewrite it all
  518. yourself from scratch?
  519.    
  520. I've actually seen and had to modify people's code that *would* have been
  521. easier to rewrite from scratch.  I suppose another concern I have is that the
  522. thing that the library doesn't do is not just a matter of added functionality,
  523. but that some basic assumption was made which doesn't hold true for my system. 
  524. As a simplified example, suppose I have a windowing library.  I use it, and
  525. then run across a case where I need to write to a window other than the one in
  526. front.  Suppose, however, that when the library puts up a window it just saves
  527. what's behind it to be later restored, implicitly assuming nobody ever writes
  528. to any window other than the one in front.  Writing to a window behind another
  529. one would be a major modification to such a library.
  530.    
  531. This is an overly easy example, but that's the type of thing I'm concerned
  532. about...
  533.    
  534.                                        Brian
  535.  
  536.  
  537.  
  538. #: 33662 S5/C++ Study Group            orig=PgUp next=     prev=
  539.     15-Aug-91  19:50:35                 No: 25
  540. Sb: #33648-C++ Programming Style
  541. Fm: John M. Dlugosz 70007,4657
  542. To: Brian Richter 76437,736
  543.    
  544. <<3. Yes, but is it easier to learn someone else's code or to rewrite it all
  545. yourself from scratch? >> depends on the code!
  546.    
  547. How about minor changes, like how the error messages are handled?  Or makeing
  548. memory management match the rest of your program?  Or recompiling for overlays?
  549. Or something really simple that you _know_ could be changed in a second if they
  550. wanted to.  Well you can!  Some things are easy to change, like adding or
  551. removing parameter checking, making simple changes to the meaning of a
  552. function, or writing a new function _almost_ like an old one.
  553.    
  554. Major functional changes are a different story.  But _having_ it means the
  555. ability to make minor changes.  And supplying source means I can supply lots of
  556. configuration options, too.
  557.  
  558.  
  559.  
  560. #: 33447 S5/C++ Study Group            orig= 1   next=     prev= 8
  561.     10-Aug-91  20:23:14                 No: 26 One Reply
  562. Sb: #33394-C++ Programming Style
  563. Fm: Mark W. Schumann 73750,3527
  564. To: Brian Richter 76437,736
  565.    
  566.    
  567. Hey, Brian, that's a Clipper Thing (tm).  Try this in Clipper '87 or 5.0x:
  568.    
  569. setcolor (mstring1)
  570. ? setcolor()       && Prints mstring1
  571. ? setcolor (mstring2)   && Prints mstring1
  572. ? setcolor (mstring3)   && Prints mstring2
  573.    
  574. Basically, Nantucket has done exactly what you suggested.  Also, the ProClip
  575. library for Clipper by Genesis uses a similar structure for a couple dozen of
  576. its functions.
  577.  
  578.  
  579.  
  580. #: 33488 S5/C++ Study Group            orig=PgUp next=     prev=
  581.     11-Aug-91  21:44:43                 No: 27
  582. Sb: #33447-C++ Programming Style
  583. Fm: Brian Richter 76437,736
  584. To: Mark W. Schumann 73750,3527
  585.    
  586. Wow, that *is* exactly what I suggested.  This is good; it makes me much more
  587. confident that perhaps this is a common idiom that will not get people
  588. confused...
  589.    
  590.                                        Brian
  591.  
  592.  
  593.  
  594. #: 33623 S5/C++ Study Group            orig=ROOT next= 128 prev= 1
  595.     15-Aug-91  01:06:46                 No: 28 Replies 4
  596. Sb: #Hungarian
  597. Fm: Greg Comeau (ComeauComp) 72331,3421
  598. To: Brian Richter 76437,736 (X)
  599.    
  600. But for arguements sake, just what does being able to distinguish between ints
  601. and long in variable names give you in the first place?  And don't you think
  602. that issue like changing the type of a variable could have negative effects to
  603. this?
  604.    
  605.    
  606.    
  607. #: 33642 S5/C++ Study Group            orig=PgUp next= 93  prev=
  608.     15-Aug-91  11:08:49                 No: 29 Replies 2
  609. Sb: #33623-#Hungarian
  610. Fm: Pete Becker (Borland) 76117,3675
  611. To: Greg Comeau (ComeauComp) 72331,3421
  612.    
  613. Greg,
  614.        I think that there _used_ to be a great benefit to using Hungarian
  615. notation, back in the bad old days before ANSI C, when Windows was in its
  616. infancy.  You often had to use two or three casts on a variable in order to get
  617. it into the right form for a generic function in the Windows API, and it was
  618. easy to get confused about the type of the variable:
  619.    
  620.        char *pzStr;
  621.    
  622.        func( (LONG)(LPSTR)pzStr );
  623.    
  624.        Most of that ugly casting has gone away, thanks to better type checking
  625. and smarter compilers.  Unfortunately, that ugly notation is still in all the
  626. Windows manuals...
  627.        -- Pete
  628.    
  629.    
  630.    
  631. #: 33646 S5/C++ Study Group            orig=PgUp next= 92  prev=
  632.     15-Aug-91  11:58:46                 No: 30 Replies 2
  633. Sb: #33642-#Hungarian
  634. Fm: Brian Richter 76437,736
  635. To: Pete Becker (Borland) 76117,3675
  636.    
  637. Actually, Windows is where I got that notation from in the first place. That
  638. was way back in '85 or so, and maybe it has indeed outlived its usefulness.
  639.    
  640. I'm amazed not to get even one response in favor of this sort of notation. From
  641. what I understand, the arguments against it amount to this:
  642.    
  643.  1) It is unnecessary with strong typechecking in ANSI C and C++;
  644.  2) It is ugly and inelegant.
  645.    
  646. To me, the most powerful disadvantage is the implicit one in this discussion:
  647.    
  648.  3) Lots of really smart people don't like it.
  649.    
  650. If I'm writing code for someone else to use, I'd want to avoid a notation that
  651. the best software guys dislike.  So to some extent it is better to "follow the
  652. crowd" for this reason.  However, I'm still reluctant to abandon it completely
  653. (perhaps retaining it in some abbreviated form) for several reasons:
  654.    
  655.    
  656. [More]
  657.    
  658. #: 33647 S5/C++ Study Group            orig=PgUp next= 84  prev=
  659.     15-Aug-91  11:58:51                 No: 31 Replies 3
  660. Sb: #33646-#Hungarian
  661. Fm: Brian Richter 76437,736
  662. To: Brian Richter 76437,736
  663.    
  664. [Continued]
  665.    
  666.    
  667. 1) It does make it clear what type everything is, without having to go up and
  668. look at the definitions of things.  I've often had to follow someone else's
  669. code, and found it very confusing.  If I see
  670.    
  671.   thingy->v_qrs
  672.    
  673. then I have to see what 'thingy' is, and then look at the structure to find out
  674. what 'v_qrs' is.  If he had used HN, just from knowing the type of one such
  675. variable, I'd know that others with the same prefix were the same type.
  676.    
  677. And I have an immediate rebuttal for that one.  The confusion arises because
  678. poor names were chosen.  If the names were logical, there'd be no confusion.
  679.    
  680. 2) It can make things shorter.  Sometimes part of the information you want to
  681. convey in a name *is* the type of the object.  You might have a temporary
  682. pointer to a record called 'temp_rec_ptr' which could be shortened to 'prTemp'
  683. in HN.  Names become more concise in those cases where it is really important
  684. to convey the type.  Granted, you have to know the abbreviations, but once you
  685. do it shouldn't be any problem.
  686.    
  687. I don't have a rebuttal for this one yet.  It seems that certain naming
  688. conventions are already part of common usage.  For example, if I saw 'n' or 'i'
  689. as a loop index, I'd guess it's an integer.  But HN would extend this to all
  690. variables.  I suspect someone will be able to argue this point, however...
  691.    
  692.                                        Brian
  693.    
  694.    
  695.    
  696. #: 33654 S5/C++ Study Group            orig=PgUp next= 76  prev=
  697.     15-Aug-91  16:14:48                 No: 32 Replies 2
  698. Sb: #33647-Hungarian
  699. Fm: Rudyard Merriam 76234,2561
  700. To: Brian Richter 76437,736
  701.    
  702. Brian
  703.    
  704. I'll continue the argument by suggesting that typing is unnecesary if you want
  705. to use Hungarian notation. If the type is implicit in the variable name then
  706. why do I have to say 'char * cpName'? The compiler should figure out from the
  707. 'cp' that it is a character pointer.
  708.    
  709. Rud (waiting for the old timers to respond)
  710.  
  711.  
  712.  
  713. #: 33657 S5/C++ Study Group            orig=PgUp next= 42  prev=
  714.     15-Aug-91  16:59:15                 No: 33 Replies 2
  715. Sb: #33654-Hungarian
  716. Fm: Brian Richter 76437,736
  717. To: Rudyard Merriam 76234,2561
  718.    
  719. I remember when I'd inadvertently come up with a name that started with "N" for
  720. a floating point value and wonder why it wasn't working.  Sometimes I'd get so
  721. frustrated I'd drop all my cards <g>.
  722.    
  723. For argument's sake, suppose the compiler were smart enough to figure out the
  724. types of variables in Hungarian notation. I'm not sure I see where that would
  725. be a problem...
  726.    
  727.                                        Brian
  728.  
  729.  
  730.  
  731. #: 33697 S5/C++ Study Group            orig=PgUp next= 39  prev=
  732.     16-Aug-91  11:31:58                 No: 34 Replies 3
  733. Sb: #33657-Hungarian
  734. Fm: Pete Becker (Borland) 76117,3675
  735. To: Brian Richter 76437,736
  736.    
  737. Brian,
  738.        Now, now, that's really not fair.  I'm sure there are some youngsters
  739. around here who have no idea why using a name that starts with 'N' would mess
  740. up floating point values.
  741.        -- Pete
  742.  
  743.  
  744.  
  745. #: 33720 S5/C++ Study Group            orig=PgUp next=PgDn prev=
  746.     16-Aug-91  18:01:08                 No: 35
  747. Sb: #33697-Hungarian
  748. Fm: Brian Richter 76437,736
  749. To: Pete Becker (Borland) 76117,3675
  750.    
  751. Well, OK; I didn't want to deprive any "old timers" of their chance to explain
  752. it, but since none have, I get to do it.
  753.    
  754. This was back when I was learning FORTRAN.  In the FORTRAN of those days, any
  755. variable starting with the letters 'I' through 'N' was automatically an
  756. integer, and you could remember that because those are the first two letters of
  757. 'integer'.  As I remember it, the compiler quietly converted the floating point
  758. value to an integer and left the programmer to puzzle over why it didn't work
  759. right.
  760.    
  761.                                        Brian
  762.  
  763.  
  764.  
  765. #: 33747 S5/C++ Study Group            orig= 34  next= 38  prev=PgUp
  766.     16-Aug-91  23:40:31                 No: 36 One Reply
  767. Sb: #33697-#Hungarian
  768. Fm: Greg Comeau (ComeauComp) 72331,3421
  769. To: Pete Becker (Borland) 76117,3675 (X)
  770.    
  771. Hey wait a second!  Don't start calling me old! ;-)  I'm young.  Really I am.
  772. ;-)
  773.    
  774.    
  775.    
  776. #: 33761 S5/C++ Study Group            orig=PgUp next=     prev=
  777.     17-Aug-91  11:23:56                 No: 37
  778. Sb: #33747-Hungarian
  779. Fm: Pete Becker (Borland) 76117,3675
  780. To: Greg Comeau (ComeauComp) 72331,3421
  781.    
  782. Greg,
  783.        Touchy, touchy...
  784.        -- Pete
  785.  
  786.  
  787.  
  788. #: 33751 S5/C++ Study Group            orig= 34  next=     prev= 36
  789.     17-Aug-91  00:53:11                 No: 38
  790. Sb: #33697-Hungarian
  791. Fm: Mark Betz [GAMERS] 76605,2346
  792. To: Pete Becker (Borland) 76117,3675 (X)
  793.    
  794. <<
  795.         Now, now, that's really not fair.  I'm sure there are some youngsters
  796. around here who have no idea why using a name that starts with 'N' would mess
  797. up floating point values. >>
  798.    
  799. I'm one (thanks for calling me a youngster).
  800.    
  801.                                                                --Mark
  802.  
  803.  
  804.  
  805. #: 33714 S5/C++ Study Group            orig= 33  next=     prev= 34
  806.     16-Aug-91  17:33:21                 No: 39 One Reply
  807. Sb: #33657-Hungarian
  808. Fm: Greg Comeau (ComeauComp) 72331,3421
  809. To: Brian Richter 76437,736
  810.    
  811. >For argument's sake, suppose the compiler were smart enough to figure out the
  812. >types of variables in Hungarian notation. I'm not sure I see where that would
  813. >be a problem...
  814.    
  815. But not only would that be superfluous in a language like C/C++, but it
  816. wouldn't be innocuous either.
  817.  
  818.  
  819.  
  820. #: 33779 S5/C++ Study Group            orig=PgUp next=     prev=
  821.     17-Aug-91  15:02:36                 No: 40 One Reply
  822. Sb: #33714-Hungarian
  823. Fm: Rudyard Merriam 76234,2561
  824. To: Greg Comeau (ComeauComp) 72331,3421
  825.    
  826. >> >> typees from Hungarian notation
  827.    
  828. >> supefluous in C/C++...not innocuous either
  829.    
  830. Why not innocuous?
  831.    
  832. Rud
  833.  
  834.  
  835.  
  836. #: 33840 S5/C++ Study Group            orig=PgUp next=     prev=
  837.     19-Aug-91  14:44:14                 No: 41
  838. Sb: #33779-Hungarian
  839. Fm: Greg Comeau (ComeauComp) 72331,3421
  840. To: Rudyard Merriam 76234,2561
  841.    
  842. >> >> typees from Hungarian notation
  843.    
  844. >> supefluous in C/C++...not innocuous either
  845.    
  846. >Why not innocuous?
  847.    
  848. Because of some of the reasons I've already mentioned in this thread.
  849. Also, my thoughts on this particular comment I made is that if Hungarian
  850. were used as the type, then how would we change the types/names of variables?
  851. That not innocuous IMO.  It could only be maintained it the types were
  852. disjoint from the name.  But that only brings us back to what we already
  853. have.
  854.  
  855.  
  856.  
  857. #: 33682 S5/C++ Study Group            orig= 32  next=     prev= 33
  858.     16-Aug-91  01:28:27                 No: 42 One Reply
  859. Sb: #33654-Hungarian
  860. Fm: Mark Betz [GAMERS] 76605,2346
  861. To: Rudyard Merriam 76234,2561
  862.    
  863. Hi, Rud. Wasn't the point of Hungarian that the type of the identifier would be
  864. readily apparent when the name was encountered in the source? I'm playing
  865. devil's advocate here. I hate it myself.
  866.    
  867.    
  868.                                                                --Mark
  869.  
  870.  
  871.  
  872. #: 33729 S5/C++ Study Group            orig=PgUp next=     prev=
  873.     16-Aug-91  18:18:23                 No: 43 Replies 4
  874. Sb: #33682-Hungarian
  875. Fm: Rudyard Merriam 76234,2561
  876. To: Mark Betz [GAMERS] 76605,2346
  877.    
  878. Mark
  879.    
  880. Petzold says Hunky notation is to avoid type mismatch errors. The MS OS/2
  881. manuals say it is "to help you readily identify the purpose and type of the
  882. funciton parameters and structure fields. ...to make the sources more readable
  883. and informative."
  884.    
  885. The printed comments appear to agree with your assertion. I suggest that if I
  886. properly name something I can be 80% certain of the variable type and usage
  887. without the Hunky fiddle faddle.
  888.    
  889. So the original question stands, why not continue the idea an have it a
  890. requirment and let the compiler use it for typing?
  891.    
  892. Rud
  893.  
  894.  
  895.  
  896. #: 33732 S5/C++ Study Group            orig=PgUp next= 54  prev=
  897.     16-Aug-91  19:15:33                 No: 44 One Reply
  898. Sb: #33729-Hungarian
  899. Fm: John M. Dlugosz 70007,4657
  900. To: Rudyard Merriam 76234,2561
  901.    
  902. <<"to help you readily identify the purpose and type of the funciton parameters
  903. and structure fields.>>  sounds fishy to me. The paramter should state the type
  904. right next to the value in the declaration.
  905.    
  906. The closest I've seen to something like that working is in a quick reference
  907. where a bunch of functions are shown as sample calls: foo(v) for example. 
  908. Before the list they say that v is a <whatever> and use it in a few sample
  909. calls.
  910.    
  911. --John
  912.  
  913.  
  914.  
  915. #: 33757 S5/C++ Study Group            orig=PgUp next=     prev=
  916.     17-Aug-91  02:39:50                 No: 45 Replies 2
  917. Sb: #33732-Hungarian
  918. Fm: Mark Betz [GAMERS] 76605,2346
  919. To: John M. Dlugosz 70007,4657
  920.    
  921. What it boils down to, John, is do you want to be able to tell the type without
  922. referring back to the declaration? If the program is large and you can't
  923. remember all the identifiers, then you'll have to refer back to the header, or
  924. wherever it was declared. The argument could be made that you should be working
  925. on well defined parts of the program, and that within the current work domain
  926. you ought to have a pretty good grasp of the identifiers in use. In that sense
  927. I agree with Pete's "hacking the code" comment.
  928.    
  929. I was thinking about writing a simple program to go through every file in a
  930. project and make a list of all the identifiers above local scope, their types,
  931. and where they are declared. I'm sure there are tools to do this, but it would
  932. be a fun excercise. I started thinking about it yesterday, and it's not as
  933. trivial as I first thought, but shouldn't take too long.
  934.    
  935.                                                        --Mark
  936.  
  937.  
  938.  
  939. #: 33786 S5/C++ Study Group            orig=PgUp next= 50  prev=
  940.     17-Aug-91  15:18:36                 No: 46 One Reply
  941. Sb: #33757-Hungarian
  942. Fm: John M. Dlugosz 70007,4657
  943. To: Mark Betz [GAMERS] 76605,2346
  944.    
  945. Well, in C++ variables are defined where needed, and hopefully functions are
  946. small anyway.  No where to go looking.  Classes do define all the contents, and
  947. referring to the class definition in the header is perfectly natural. I usually
  948. keep it in an inset window in the upper right corner of the screen.
  949.    
  950. A utility to spot all global variables might be handy, for studying code you
  951. just got.  You mean globaly public values (which will be in a header somewhere,
  952. too) or static variables in a file?
  953.    
  954. --John
  955.  
  956.  
  957.  
  958. #: 33793 S5/C++ Study Group            orig=PgUp next=     prev=
  959.     17-Aug-91  16:52:48                 No: 47 One Reply
  960. Sb: #33786-Hungarian
  961. Fm: Mark Betz [GAMERS] 76605,2346
  962. To: John M. Dlugosz 70007,4657
  963.    
  964. Hi, John. I expect to write the utility to list all identifiers, static and
  965. otherwise, that have greater than local scope. That should include class and
  966. struct members as well. It's also got to keep track of the types of al the
  967. identifiers, some of which may inherit their types, so it's going to be an
  968. interesting project.
  969.    
  970.                                                --Mark
  971.  
  972.  
  973.  
  974. #: 33805 S5/C++ Study Group            orig=PgUp next=     prev=
  975.     18-Aug-91  03:08:53                 No: 48 One Reply
  976. Sb: #33793-Hungarian
  977. Fm: John M. Dlugosz 70007,4657
  978. To: Mark Betz [GAMERS] 76605,2346
  979.    
  980. Well, it was the wish for a cross-referencer that got me on the road to
  981. studying C++ in a more serious way.  Good luck.
  982.    
  983. --John
  984.  
  985.  
  986.  
  987. #: 33821 S5/C++ Study Group            orig=PgUp next=     prev=
  988.     18-Aug-91  18:21:23                 No: 49
  989. Sb: #33805-Hungarian
  990. Fm: Mark Betz [GAMERS] 76605,2346
  991. To: John M. Dlugosz 70007,4657
  992.    
  993. Thanks! I may need to come to you for help on it <g>. It'll be freeware, so
  994. I'll likely post my ideas and ask everyone to contribute.
  995.    
  996.    
  997.                                                        --Mark
  998.  
  999.  
  1000.  
  1001. #: 33842 S5/C++ Study Group            orig= 45  next=     prev= 46
  1002.     19-Aug-91  14:44:26                 No: 50 One Reply
  1003. Sb: #33757-#Hungarian
  1004. Fm: Greg Comeau (ComeauComp) 72331,3421
  1005. To: Mark Betz [GAMERS] 76605,2346 (X)
  1006.    
  1007. >What it boils down to, John, is do you want to be able to tell the type
  1008. >without referring back to the declaration? If the program is large and you
  1009. >can't remember all the identifiers, then you'll have to refer back to the
  1010.    
  1011. Well, there are (proper?) ways around that.  But IMO, just trying to grasp a
  1012. humongous project that is beyond the scope of one individual make it
  1013. apparent that this is not a language problem at heart.  Tools are the route
  1014. to go.  Static analysis is one route.  Browsers are another.  But not quite
  1015. either one or the other is the route to go.  Both are and hence this C++
  1016. environment idea you hear me mention once is a while is the ultimate goal.
  1017. Not much different that the way some spelling checkers and help systems work
  1018. not for starters would be nice.
  1019.    
  1020.    
  1021.  
  1022.  
  1023. #: 33855 S5/C++ Study Group            orig=PgUp next=     prev=
  1024.     19-Aug-91  16:14:55                 No: 51 One Reply
  1025. Sb: #33842-Hungarian
  1026. Fm: Mark Betz [GAMERS] 76605,2346
  1027. To: Greg Comeau (ComeauComp) 72331,3421
  1028.    
  1029. Good point, Greg. I think it isn't a language issue. I'm considering writing a
  1030. small program to cross ref all identifiers in a project by looking at either
  1031. the project or make files, and then parsing each source file to find the
  1032. identifiers and their types. Would something like this be useful, do you think?
  1033.    
  1034.                                                        --Mark
  1035.  
  1036.  
  1037.  
  1038. #: 33919 S5/C++ Study Group            orig=PgUp next=     prev=
  1039.     20-Aug-91  15:19:25                 No: 52 One Reply
  1040. Sb: #33855-#Hungarian
  1041. Fm: Greg Comeau (ComeauComp) 72331,3421
  1042. To: Mark Betz [GAMERS] 76605,2346 (X)
  1043.    
  1044. It would have use.  Just don't underestimate its complexity.  You got many
  1045. issue to resolve if done properly.
  1046.    
  1047.    
  1048.    
  1049. #: 33924 S5/C++ Study Group            orig=PgUp next=     prev=
  1050.     20-Aug-91  15:37:08                 No: 53
  1051. Sb: #33919-Hungarian
  1052. Fm: Mark Betz [GAMERS] 76605,2346
  1053. To: Greg Comeau (ComeauComp) 72331,3421
  1054.    
  1055. Thanks Greg. That's something I've come to realize as I contemplated the
  1056. project. Since you've brought up the idea of "done properly" let me throw the
  1057. question into the arena: What should a C++ identifier cross-referencer do if
  1058. it's to be "done properly"?
  1059.    
  1060.    
  1061.                                                        --Mark
  1062.  
  1063.  
  1064.  
  1065. #: 33748 S5/C++ Study Group            orig= 43  next=PgDn prev= 44
  1066.     16-Aug-91  23:40:33                 No: 54
  1067. Sb: #33729-Hungarian
  1068. Fm: Greg Comeau (ComeauComp) 72331,3421
  1069. To: Rudyard Merriam 76234,2561 (X)
  1070.    
  1071. Why not let the compiler use it for typing?  Well, enough people seem to
  1072. dislike it, even just from a readability standpoint.
  1073.  
  1074.  
  1075.  
  1076. #: 33756 S5/C++ Study Group            orig= 43  next= 72  prev=PgUp
  1077.     17-Aug-91  01:54:57                 No: 55 Replies 2
  1078. Sb: #33729-#Hungarian
  1079. Fm: Mark Betz [GAMERS] 76605,2346
  1080. To: Rudyard Merriam 76234,2561 (X)
  1081.    
  1082. Ok, I see where you're heading. I thought you were saying that the compilers
  1083. already did something with Hungarian notation.
  1084.    
  1085. It's an interesting idea. Instead of char *somechar you would declare
  1086. cpSomeChar and the compiler would know what it is by the first two letters. It
  1087. would be workable, and you'd gain explicit type recognition based on identifier
  1088. names. Not a bad idea at all. How would you handle custom types? Have to allow
  1089. the programmer to define new type codes as we currently can.
  1090.    
  1091.    
  1092.                                                        --Mark
  1093.    
  1094.    
  1095.    
  1096.    
  1097. #: 33762 S5/C++ Study Group            orig=PgUp next= 67  prev=
  1098.     17-Aug-91  11:24:06                 No: 56 Replies 3
  1099. Sb: #33756-#Hungarian
  1100. Fm: Pete Becker (Borland) 76117,3675
  1101. To: Mark Betz [GAMERS] 76605,2346
  1102.    
  1103. Mark,
  1104.        NO, NO, NO!!!!  You kids who haven't had the benefit of programming in
  1105. FORTRAN obviously haven't learned the dangers of implicit types.  But putting
  1106. that aside, and assuming arguendo that implicit types are a good thing, you
  1107. still have a significant decision to make: are explicit type declarations
  1108. required (even though they're redundant)?  If not, you've got a BASIC-style
  1109. maintenance problem if you ever change the name of a variable and miss one or
  1110. two occurrences of its name. If so, how do you handle a conflict between the
  1111. declared type and the implicit type?  I suppose it has to be an error.  Which
  1112. gets you right into the nit-picking style of Pascal. No thanks...
  1113.        -- Pete
  1114.    
  1115.    
  1116.    
  1117. #: 33766 S5/C++ Study Group            orig=PgUp next=PgDn prev=
  1118.     17-Aug-91  13:53:14                 No: 57
  1119. Sb: #33762-Hungarian
  1120. Fm: Brian Richter 76437,736
  1121. To: Pete Becker (Borland) 76117,3675
  1122.    
  1123. >> ...nit-picking style of Pascal
  1124.    
  1125. That's the best argument I've heard yet.  HN is certainly one step closer to
  1126. implicit types.  If you use them correctly, you evidently expect all the
  1127. prefixes to match.  And whether you check or the compiler checks, it sort of
  1128. amounts to the same thing...
  1129.    
  1130.                                        Brian
  1131.  
  1132.  
  1133.  
  1134. #: 33791 S5/C++ Study Group            orig= 56  next= 66  prev=PgUp
  1135.     17-Aug-91  16:16:32                 No: 58 One Reply
  1136. Sb: #33762-Hungarian
  1137. Fm: Mark Betz [GAMERS] 76605,2346
  1138. To: Pete Becker (Borland) 76117,3675
  1139.    
  1140. Good point, Pete. And thanks again! That's twice you've inplied I'm a young'un
  1141. <g>. I may be... but sometimes 31 feels old.
  1142.    
  1143. I see what you're saying. In C++ to alter the type of an identifier you simply
  1144. change the declaration. In any case, while I might approve of the idea of
  1145. self-identifying types in theory, I agree with you that it's a solution in
  1146. search of a problem. When I'm maintaining code I have to understand it to an
  1147. extent that makes me familiar with what the identifiers are and what they do
  1148. anyway. To do less is to risk breaking the thing.
  1149.    
  1150.    
  1151.                                                        --Mark
  1152.  
  1153.  
  1154.  
  1155. #: 33844 S5/C++ Study Group            orig=PgUp next=     prev=
  1156.     19-Aug-91  14:44:32                 No: 59 One Reply
  1157. Sb: #33791-#Hungarian
  1158. Fm: Greg Comeau (ComeauComp) 72331,3421
  1159. To: Mark Betz [GAMERS] 76605,2346 (X)
  1160.    
  1161. Jeesh are here you got me think you were 15 in your previous message. Me: I
  1162. must be a youngen too: I'm 32.  Or is that where the line is drawn? ;-)
  1163.    
  1164.    
  1165.    
  1166. #: 33856 S5/C++ Study Group            orig=PgUp next=     prev=
  1167.     19-Aug-91  16:14:59                 No: 60 One Reply
  1168. Sb: #33844-Hungarian
  1169. Fm: Mark Betz [GAMERS] 76605,2346
  1170. To: Greg Comeau (ComeauComp) 72331,3421
  1171.    
  1172. >> think you were 15...
  1173.    
  1174. Well, there are probably many 15 year-olds who know more about C++ than I do
  1175. <g>.
  1176.    
  1177. You're right, the cut-off is 31. Sorry... old man :)
  1178.    
  1179.    
  1180.                                                        --Mark
  1181.  
  1182.  
  1183.  
  1184. #: 33866 S5/C++ Study Group            orig=PgUp next=     prev=
  1185.     19-Aug-91  17:45:08                 No: 61 Replies 2
  1186. Sb: #33856-Hungarian
  1187. Fm: John M. Dlugosz 70007,4657
  1188. To: Mark Betz [GAMERS] 76605,2346
  1189.    
  1190. I'm 24, and starting to feel "old".  Why?  I'm putting socks on my birthday
  1191. list.
  1192.    
  1193. --John
  1194.  
  1195.  
  1196.  
  1197. #: 33884 S5/C++ Study Group            orig=PgUp next= 65  prev=
  1198.     19-Aug-91  20:51:44                 No: 62 Replies 2
  1199. Sb: #33866-Hungarian
  1200. Fm: Mark Betz [GAMERS] 76605,2346
  1201. To: John M. Dlugosz 70007,4657
  1202.    
  1203. That *is* old. Not being able to think of anything neater than that means that
  1204. a) you are losing your imagination, or b) you are too lazy/busy to go to the
  1205. store and buy socks. I fall firmly in category 2 (I hope) <g>.
  1206.    
  1207.    
  1208.                                                        --Mark
  1209.  
  1210.  
  1211.  
  1212. #: 33897 S5/C++ Study Group            orig=PgUp next=PgDn prev=
  1213.     20-Aug-91  00:25:58                 No: 63
  1214. Sb: #33884-Hungarian
  1215. Fm: John M. Dlugosz 70007,4657
  1216. To: Mark Betz [GAMERS] 76605,2346 (X)
  1217.    
  1218. No, its just that this is now something I really need.  I spend fifty bucks for
  1219. a box of socks.  (special order from Burlington)
  1220.    
  1221. --John
  1222.  
  1223.  
  1224.  
  1225. #: 33911 S5/C++ Study Group            orig= 62  next=     prev=PgUp
  1226.     20-Aug-91  11:50:56                 No: 64
  1227. Sb: #33884-Hungarian
  1228. Fm: Rudyard Merriam 76234,2561
  1229. To: Mark Betz [GAMERS] 76605,2346 (X)
  1230.    
  1231. Mark
  1232.    
  1233. You have to realize that John's socks are big! They could be used to cover all
  1234. the golf clubs in a set at one time! <g>
  1235.    
  1236. Rud
  1237.  
  1238.  
  1239.  
  1240. #: 33909 S5/C++ Study Group            orig= 61  next=     prev= 62
  1241.     20-Aug-91  10:29:27                 No: 65
  1242. Sb: #33866-Hungarian
  1243. Fm: Skip Key 73130,2102
  1244. To: John M. Dlugosz 70007,4657
  1245.    
  1246. John,
  1247.        You _are_ old at 24.  I'm 22 and I feel old most of the time so you must
  1248. be<g>.
  1249.    
  1250. Skip
  1251.  
  1252.  
  1253.  
  1254. #: 33843 S5/C++ Study Group            orig= 56  next=     prev= 58
  1255.     19-Aug-91  14:44:28                 No: 66
  1256. Sb: #33762-Hungarian
  1257. Fm: Greg Comeau (ComeauComp) 72331,3421
  1258. To: Pete Becker (Borland) 76117,3675
  1259.    
  1260. Exactamundo!
  1261.  
  1262.  
  1263.  
  1264. #: 33787 S5/C++ Study Group            orig= 55  next=     prev= 56
  1265.     17-Aug-91  15:18:41                 No: 67 One Reply
  1266. Sb: #33756-Hungarian
  1267. Fm: John M. Dlugosz 70007,4657
  1268. To: Mark Betz [GAMERS] 76605,2346
  1269.    
  1270. Here is a tangent.  I'm designing a little languge for an editor macro
  1271. language, and my big idea at this point is typeless (more typeless than
  1272. anything you've seen before!).  Would a tagged notation make sence in this
  1273. case?
  1274.    
  1275. --John
  1276.  
  1277.  
  1278.  
  1279. #: 33794 S5/C++ Study Group            orig=PgUp next=     prev=
  1280.     17-Aug-91  16:52:51                 No: 68 One Reply
  1281. Sb: #33787-Hungarian
  1282. Fm: Mark Betz [GAMERS] 76605,2346
  1283. To: John M. Dlugosz 70007,4657
  1284.    
  1285. That'd be hard to answer, John, without knowing what the macro language will
  1286. do. Most macro languages I've used in application programs don't deal with the
  1287. concept of type much at all, ouside of numerical types. What's the basic goal
  1288. of the language?
  1289.    
  1290.                                                        --Mark
  1291.  
  1292.  
  1293.  
  1294. #: 33806 S5/C++ Study Group            orig=PgUp next=     prev=
  1295.     18-Aug-91  03:09:01                 No: 69 One Reply
  1296. Sb: #33794-Hungarian
  1297. Fm: John M. Dlugosz 70007,4657
  1298. To: Mark Betz [GAMERS] 76605,2346
  1299.    
  1300. <<the basic goal of the language>>  It should be powerful enough to implement
  1301. most of the editor commands in it.  functions can be bound to C++ code, which
  1302. will handle all the primitives.
  1303.    
  1304. I will be object oriented, in the sense that you can take an existing object
  1305. (say, a edit window for C code, which has key bindings and functions used by
  1306. them and whatnot) and make a new thing from it, adding code, changing code,
  1307. altering settings, etc., but not messing up the original. Then you can throw it
  1308. away when done with it and it goes away seemlessly.
  1309.    
  1310. Everything it deals with is an object, with its own member functions.
  1311. Primitives are numbers, strings, arrays, functions, messages. Then you have
  1312. structured types, which hold a bunch of named fields. (fields can hold
  1313. functions, and you can then send messages to call them)
  1314.    
  1315. The idea is that you have class scope.  when "in" a member function, your
  1316. symbol table are other fields of that object.  To make something a little
  1317. different, you clone an existing object and start making changes.  The
  1318. implementation acually shares as much as possible between the two.
  1319.    
  1320. For the class things, you see that there are no types.  Every object can have
  1321. fields added and removed at will.  An object is not of a type; rather it just
  1322. has a bunch of named fields.  It may happen to have the same names as another
  1323. object.
  1324.    
  1325. What do you think?
  1326.    
  1327. --John
  1328.    
  1329. P.S.  change the subject when you reply!
  1330.  
  1331.  
  1332.  
  1333. #: 33845 S5/C++ Study Group            orig=PgUp next=     prev=
  1334.     19-Aug-91  14:44:36                 No: 70 One Reply
  1335. Sb: #33806-Hungarian
  1336. Fm: Greg Comeau (ComeauComp) 72331,3421
  1337. To: John M. Dlugosz 70007,4657
  1338.    
  1339. I think that you're going to have some fun, and possible some interesting
  1340. research in front of you.
  1341.    
  1342. Do you surmise that you'll be able to resolve all the contexts of a given class
  1343. to resolve ambiguity?
  1344.  
  1345.  
  1346.  
  1347. #: 33867 S5/C++ Study Group            orig=PgUp next=     prev=
  1348.     19-Aug-91  17:45:13                 No: 71
  1349. Sb: #33845-Hungarian
  1350. Fm: John M. Dlugosz 70007,4657
  1351. To: Greg Comeau (ComeauComp) 72331,3421
  1352.    
  1353. sorry, I lost the thread.
  1354.  
  1355.  
  1356.  
  1357. #: 33758 S5/C++ Study Group            orig= 43  next=     prev= 55
  1358.     17-Aug-91  05:40:11                 No: 72 One Reply
  1359. Sb: #33729-Hungarian
  1360. Fm: Sidney Markowitz 75140,137
  1361. To: Rudyard Merriam 76234,2561 (X)
  1362.    
  1363.  >> why not ... let the compiler use it for typing? <<
  1364.    
  1365. In ANSI C and in C++ there is already a way to indicate the type of a variable
  1366. in a way that avoids type mismatch errors and is enforced by the compiler. This
  1367. way is more flexible than Hungarian notation in that it can handle any type,
  1368. including user defined structs and classes, it does not interfere with the
  1369. readability of descriptive variable names, and it localizes the changes that
  1370. are necessary when you decide to change the data structures used in
  1371. implementing your program.
  1372.    
  1373. Instead of specifying the type in the first few characters of a variable's
  1374. name, you specify it explicitly in the variable definition or declaration, or
  1375. in the function prototype.
  1376.    
  1377.  -- sidney
  1378.  
  1379.  
  1380.  
  1381. #: 33780 S5/C++ Study Group            orig=PgUp next=     prev=
  1382.     17-Aug-91  15:02:41                 No: 73 Replies 2
  1383. Sb: #33758-#Hungarian
  1384. Fm: Rudyard Merriam 76234,2561
  1385. To: Sidney Markowitz 75140,137 (X)
  1386.    
  1387. sidney
  1388.    
  1389. But FORTRAN did use a primitive form of HN to type variables. Why did languages
  1390. like C/C++ and Pascal reject that usage and introduce type declarations?
  1391.    
  1392. I think the best argument is the localization of changes.
  1393.    
  1394. Rud
  1395.    
  1396.    
  1397.    
  1398.    
  1399. #: 33801 S5/C++ Study Group            orig=PgUp next=PgDn prev=
  1400.     17-Aug-91  23:04:45                 No: 74
  1401. Sb: #33780-Hungarian
  1402. Fm: Sidney Markowitz 75140,137
  1403. To: Rudyard Merriam 76234,2561
  1404.    
  1405. Rud -
  1406.    
  1407. FORTRAN introduced a primitive form of HN to type variables, and it provided a
  1408. chance for people to learn what is wrong with that system. 1) FORTRAN proved to
  1409. be too poor in the number of types available. Extensions to the type system did
  1410. not continue the implicit typing of variables based on name. 2) If you are
  1411. going to rely on the variable name to implicitly type it, then you have to not
  1412. require explicit declarations of variables. That leads to typos not being
  1413. caught by the compiler if variables don't have to be declared before use. If
  1414. you have to declare variables before use, then you aren't fully relying on the
  1415. implicit typing based on the name.
  1416.    
  1417. I agree that localization of changes is an important reason, but I also am
  1418. strongly in favor of a style of programming in which you make up data
  1419. structures to match your algorithms and encapsulate them as types with their
  1420. own functions. In OOP, that's called classes and methods. And if you do that,
  1421. your type names are class names and HN makes absolutely no sense at all.
  1422.    
  1423.  -- sidney
  1424.  
  1425.  
  1426.  
  1427. #: 33846 S5/C++ Study Group            orig= 73  next=     prev=PgUp
  1428.     19-Aug-91  14:44:38                 No: 75
  1429. Sb: #33780-Hungarian
  1430. Fm: Greg Comeau (ComeauComp) 72331,3421
  1431. To: Rudyard Merriam 76234,2561
  1432.    
  1433. But FORTRAN's HN was implicit.  Even worse IMO.  Further compounded with
  1434. FORTRAN was that you could also be explicit and if I recall proporly could also
  1435. override any defaults.  My comment: Oy!
  1436.  
  1437.  
  1438.  
  1439. #: 33688 S5/C++ Study Group            orig= 31  next= 83  prev= 32
  1440.     16-Aug-91  09:00:19                 No: 76 Replies 2
  1441. Sb: #33647-Hungarian
  1442. Fm: Ben Sano 72401,2736
  1443. To: Brian Richter 76437,736
  1444.    
  1445. Brian
  1446.    
  1447. Sounds almost as useful as a comment an even less likely to be changed in
  1448. case of maintainence, since you have to change it in more then one place.
  1449.    
  1450. And since C++ allows you to define new types why the possiblities are
  1451. ENDLESS.
  1452.    
  1453. aLstkUGI of course is a variable called 'a' that is a Stack of Unbounded
  1454. implementation with garbage collection and an iterator.
  1455.    
  1456. I would rather write COBOL.
  1457.    
  1458. --Ben
  1459.  
  1460.  
  1461.  
  1462. #: 33715 S5/C++ Study Group            orig=PgUp next= 80  prev=
  1463.     16-Aug-91  17:33:24                 No: 77 One Reply
  1464. Sb: #33688-Hungarian
  1465. Fm: Greg Comeau (ComeauComp) 72331,3421
  1466. To: Ben Sano 72401,2736
  1467.    
  1468. >aLstkUGI
  1469.    
  1470. Wait!  What's the L mean? ;-)
  1471.  
  1472.  
  1473.  
  1474. #: 33735 S5/C++ Study Group            orig=PgUp next=     prev=
  1475.     16-Aug-91  20:31:55                 No: 78 One Reply
  1476. Sb: #33715-Hungarian
  1477. Fm: Ben Sano 72401,2736
  1478. To: Greg Comeau (ComeauComp) 72331,3421 (X)
  1479.    
  1480. Greg
  1481.  >Wait! What's the L mean?
  1482.    
  1483. Why, it used to be a List but when I changed it into a Stack I forgot to
  1484. change the name! ;-)
  1485.    
  1486. --Ben
  1487.  
  1488.  
  1489.  
  1490. #: 33745 S5/C++ Study Group            orig=PgUp next=     prev=
  1491.     16-Aug-91  23:03:57                 No: 79
  1492. Sb: #33735-Hungarian
  1493. Fm: Greg Comeau (ComeauComp) 72331,3421
  1494. To: Ben Sano 72401,2736 (X)
  1495.    
  1496. Oy!
  1497.  
  1498.  
  1499.  
  1500. #: 33721 S5/C++ Study Group            orig= 76  next=     prev= 77
  1501.     16-Aug-91  18:01:10                 No: 80 One Reply
  1502. Sb: #33688-Hungarian
  1503. Fm: Brian Richter 76437,736
  1504. To: Ben Sano 72401,2736
  1505.    
  1506. That's been my experience in C++ too; you just get too darn many abbreviations
  1507. to remember.  (I like your example!)  This is what made me doubt HN enough to
  1508. start this discussion...
  1509.    
  1510.                                        Brian
  1511.  
  1512.  
  1513.  
  1514. #: 33736 S5/C++ Study Group            orig=PgUp next=     prev=
  1515.     16-Aug-91  20:32:02                 No: 81 One Reply
  1516. Sb: #33721-Hungarian
  1517. Fm: Ben Sano 72401,2736
  1518. To: Brian Richter 76437,736
  1519.    
  1520. Brian
  1521.    
  1522.  Glad you liked the examples but I didn't make them up you know, the
  1523. classification system is adapted from Grady Booch's Ada components.
  1524.    
  1525. Which goes like this:
  1526.    
  1527.   Software Form ::= Concurrency Form, Space Form, Iterator Form, Garbage
  1528.                     Collection Form;
  1529.    
  1530.   Concurrency Form ::= Sequential | Guarded | Concurrent | Multiple;
  1531.   Space Form       ::= Bounded | Unbounded;
  1532.   Iterator Form    ::= Noniterator | Iterator;
  1533.   Garbage Collected Form ::= Managed | Unmanaged | Controlled;
  1534.    
  1535. In languages that allow Abstract Data Types it not a joke, in C++ which
  1536. tries very hard and largely successfully to make user defined types look
  1537. like those of the base language Hungarian notation becomes a disaster.
  1538.    
  1539. --Ben
  1540.  
  1541.  
  1542.  
  1543. #: 33767 S5/C++ Study Group            orig=PgUp next=     prev=
  1544.     17-Aug-91  13:53:18                 No: 82
  1545. Sb: #33736-Hungarian
  1546. Fm: Brian Richter 76437,736
  1547. To: Ben Sano 72401,2736
  1548.    
  1549. So are you saying that for such Abstract Data Types, HN really helps?
  1550.    
  1551.                                        Brian
  1552.  
  1553.  
  1554.  
  1555. #: 33713 S5/C++ Study Group            orig= 31  next=     prev= 76
  1556.     16-Aug-91  17:33:16                 No: 83
  1557. Sb: #33647-Hungarian
  1558. Fm: Greg Comeau (ComeauComp) 72331,3421
  1559. To: Brian Richter 76437,736
  1560.    
  1561. >1) It does make it clear what type everything is, without having to go up and
  1562. >look at the definitions of things.  I've often had to follow someone else's
  1563. >code, and found it very confusing.
  1564.    
  1565. But the price to pay for looking up the stuff (shouldn't ya be sure
  1566. anyway??) is lower than the price of a misleading name.  No different than
  1567. an ambiguous, bogus, or outdated comment.
  1568.    
  1569. Also, I don't see how issues like C's typedef and/or C++ class names can be
  1570. maintained in any managable order (ah, some of my examples with Petzold are
  1571. starting to come back!).  Again, it just breaks down too quickly.
  1572.    
  1573. Anyway, I don't think it a burden for a programmer to know what her/his
  1574. program is doing.
  1575.    
  1576. >It seems that certain naming conventions are already part of common usage.
  1577. >For example, if I saw 'n' or 'i' as a loop index, I'd guess it's an integer.
  1578.    
  1579. As I mentioned the idea is not all that far fetched, and most certainly
  1580. names like i are idioms for a temp integer or somesuch.  Or p for pointer.
  1581. But I don't think it can go much further than that for general programming.
  1582. However, I do see it having a more, but limited, use in sub-systems, perhaps
  1583. especially where names clashes would normally occur.
  1584.  
  1585.  
  1586.  
  1587. #: 33712 S5/C++ Study Group            orig= 30  next=     prev= 31
  1588.     16-Aug-91  17:33:07                 No: 84 One Reply
  1589. Sb: #33646-Hungarian
  1590. Fm: Greg Comeau (ComeauComp) 72331,3421
  1591. To: Brian Richter 76437,736
  1592.    
  1593. >To me, the most powerful disadvantage is the implicit one in this discussion:
  1594. >
  1595. > 3) Lots of really smart people don't like it.
  1596.    
  1597. To me, it's a serious mistake to decide based up that.  Realize that the
  1598. so-called smart people suffer from knowing too much for their own good many
  1599. times.  Also, the so-called smart people have tendencies to cult'isize.
  1600. That's bad all around.  Smarties should be 3rd degree questioned and if they
  1601. can't defend themselves should be literally boo'd right off the stage and of
  1602. course, not be listened to just because they said something wrong amidst a
  1603. bunch of right stuff.
  1604.  
  1605.  
  1606.  
  1607. #: 33768 S5/C++ Study Group            orig=PgUp next=     prev=
  1608.     17-Aug-91  13:53:24                 No: 85 Replies 2
  1609. Sb: #33712-#Hungarian
  1610. Fm: Brian Richter 76437,736
  1611. To: Greg Comeau (ComeauComp) 72331,3421
  1612.    
  1613. I didn't want to admit it, but of course you're absolutely right!  "Lots of
  1614. really smart people don't like it" is not on its own a valid reason not to use
  1615. HN.  Realizing this makes the decision no easier than it was in the beginning.
  1616.    
  1617. OTOH, I think all youse guys defended yourselves pretty well. <g>
  1618.    
  1619. But theoretically, then, even after listening to this entire one-sided
  1620. discussion, if I still thought that HN was good I should go right on using it. 
  1621. Evidently Petzold feels strongly enough about it to do just that.  But I have
  1622. two arguments that are related but not the same as my original one, given here
  1623. in order of increasing persuasive power:
  1624.    
  1625. 1) Lots of experienced programmers have evidently found it not to be helpful. 
  1626. I admit, this one is somewhat of a guess on my part.  I'll bet a good number of
  1627. the people who argue against HN have never even tried it; they just don't think
  1628. it looks nice.  And I do know from experience that it's not nearly so cryptic
  1629. in actual use as it looks to an outsider reading it.  But, in general, I think
  1630. I know who's who out there, and many may have dabbled in Windows programming or
  1631. had some other sort of actual experience.
  1632.    
  1633. Not only that, but...
  1634.    
  1635.    
  1636. 2) Most of the programming world does not accept HN.  This is perhaps similar
  1637. to my original argument, in a sense.  But I figure that when I'm writing code,
  1638. it's not just for myself to read.  Other people are going to have to read it
  1639. too.  So even if I personally find something easier to read, if nobody else can
  1640. understand it I'm putting myself at a disadvantage.
  1641.    
  1642. And suppose I were going to write a class library of some sort, which I thought
  1643. could really be better than anything else on the market.  If I stuck to HN,
  1644. most people would take that as a minus and probably wouldn't buy my library.
  1645.    
  1646. So I think using a notation that is acceptable to others is very important. If
  1647. I really didn't care about other people reading it, I wouldn't even have to use
  1648. comments, because what programmer would be stupid enough not to remember his
  1649. own code! <g>
  1650.    
  1651. Seriously, it's a tough question, but I think I'm going to stop using HN. I'm
  1652. working on some experiments in de-Hungarianizing something right now...
  1653.    
  1654.                                        Brian
  1655.  
  1656.  
  1657.  
  1658. #: 33788 S5/C++ Study Group            orig=PgUp next= 90  prev=
  1659.     17-Aug-91  15:18:46                 No: 86 Replies 2
  1660. Sb: #33768-Hungarian
  1661. Fm: John M. Dlugosz 70007,4657
  1662. To: Brian Richter 76437,736
  1663.    
  1664. A different situation:  you are looking at a code _fragment_ in a book. Where
  1665. to look for variable definitions and functions?  You want full info on that
  1666. page.  Tagging the types of the variables (and omitting the definitions from
  1667. the fragment) might make sence.
  1668.    
  1669. --John
  1670.  
  1671.  
  1672.  
  1673. #: 33796 S5/C++ Study Group            orig=PgUp next=PgDn prev=
  1674.     17-Aug-91  17:32:49                 No: 87
  1675. Sb: #33788-Hungarian
  1676. Fm: Brian Richter 76437,736
  1677. To: John M. Dlugosz 70007,4657
  1678.    
  1679. If I were writing a book, I might do something like this:
  1680.    
  1681.  char s[];
  1682.  char* p;
  1683.  char c;
  1684.    
  1685.  ...
  1686.    
  1687.  for (p = s; *p != '\0'; p++)
  1688.    *p = c;
  1689.    
  1690. To briefly hop threads, I'd code it this way and expect the compiler to know
  1691. that it's comparing something with zero.  It's just clearer this way...
  1692.    
  1693.                                        Brian
  1694.  
  1695.  
  1696.  
  1697. #: 33848 S5/C++ Study Group            orig= 86  next=     prev=PgUp
  1698.     19-Aug-91  14:44:47                 No: 88 One Reply
  1699. Sb: #33788-Hungarian
  1700. Fm: Greg Comeau (ComeauComp) 72331,3421
  1701. To: John M. Dlugosz 70007,4657
  1702.    
  1703. As I commented about the HN thread discussion I had with Petzold now in
  1704. oblivion, any chance of getting this thread lib'ed up somehow?
  1705.  
  1706.  
  1707.  
  1708. #: 33868 S5/C++ Study Group            orig=PgUp next=     prev=
  1709.     19-Aug-91  17:45:18                 No: 89
  1710. Sb: #33848-Hungarian
  1711. Fm: John M. Dlugosz 70007,4657
  1712. To: Greg Comeau (ComeauComp) 72331,3421
  1713.    
  1714. Sure.  I'll grab the Hungarian thread tonight and upload.  I've been meaning to
  1715. grab the #now what thread anyway.
  1716.    
  1717. --John
  1718.  
  1719.  
  1720.  
  1721. #: 33847 S5/C++ Study Group            orig= 85  next=     prev= 86
  1722.     19-Aug-91  14:44:44                 No: 90 One Reply
  1723. Sb: #33768-Hungarian
  1724. Fm: Greg Comeau (ComeauComp) 72331,3421
  1725. To: Brian Richter 76437,736
  1726.    
  1727. >I'll bet a good number of the people who argue against HN have never even
  1728. >tried it; they just don't think it looks nice.
  1729.    
  1730. If it matters any, although I've never used the HN that Windows uses, I have
  1731. invented my own both in typed and untypes languages and except for rarer
  1732. situations it was most certainly more trouble than it was worth.
  1733. Furthermore, it was bad enough to inflict me on myself, but I also inflicted
  1734. such composition upon others for a brief period of time.  No go.
  1735.  
  1736.  
  1737.  
  1738. #: 33873 S5/C++ Study Group            orig=PgUp next=     prev=
  1739.     19-Aug-91  17:51:15                 No: 91
  1740. Sb: #33847-Hungarian
  1741. Fm: Brian Richter 76437,736
  1742. To: Greg Comeau (ComeauComp) 72331,3421
  1743.    
  1744. This thread is going to stop me just short of inflicting it on others. Although
  1745. there may be some code of mine out there that's too late to stop before others
  1746. see it.
  1747.    
  1748. I'm relieved to hear that I'm not the only one who has tried it.  It *sounded*
  1749. good...
  1750.    
  1751.                                        Brian
  1752.  
  1753.  
  1754.  
  1755. #: 33693 S5/C++ Study Group            orig= 29  next=     prev= 30
  1756.     16-Aug-91  10:58:27                 No: 92
  1757. Sb: #33642-Hungarian
  1758. Fm: Greg Comeau (ComeauComp) 72331,3421
  1759. To: Pete Becker (Borland) 76117,3675 (X)
  1760.    
  1761. >       I think that there _used_ to be a great benefit to using Hungarian
  1762. >notation, back in the bad old days before ANSI C, when Windows was in its
  1763. >infancy.
  1764.    
  1765. There used to be only in *some* contexts.  That's what I meant by my
  1766. previous comment in this thread of "This is not to say that tangents off the
  1767. essence of [Hungarian] aren't usable, but in and of itself [Hungarian] is
  1768. not practical."  That is to say: I do see the merit in naming conventions,
  1769. particularly in a sub-system like Windows.  I do not see it being used
  1770. generically in total all over though, whether in "Classic C" or not.  And
  1771. even having said what I've said about it having a limited use, something
  1772. like Windows has most certainly brought it past the limit.
  1773.  
  1774.  
  1775.  
  1776. #: 33645 S5/C++ Study Group            orig= 28  next= 122 prev= 29
  1777.     15-Aug-91  11:58:41                 No: 93 Replies 4
  1778. Sb: #33623-Hungarian
  1779. Fm: Brian Richter 76437,736
  1780. To: Greg Comeau (ComeauComp) 72331,3421
  1781.    
  1782. For argument's sake, then, it makes implicit conversions more apparent.  If you
  1783. have
  1784.    
  1785.        lSize = nNumBytes
  1786.    
  1787. then you know that 'nNumBytes' can only hold an integer value, and if this
  1788. occurs all over, you can think to yourself, "Gee, either 'lSize' only needs to
  1789. be an 'int' or 'nNumBytes' ought to be a 'long'."
  1790.    
  1791. Changing the type of a variable isn't too much of a problem; it's just a
  1792. find-and-replace operation.  It's a bit tedious, but doesn't present any
  1793. special difficulties.
  1794.    
  1795. I must say, I'm surprised that of all the responses on this topic, not one has
  1796. been in favor of Hungarian notation!
  1797.    
  1798.                                        Brian
  1799.  
  1800.  
  1801.  
  1802. #: 33660 S5/C++ Study Group            orig=PgUp next= 98  prev=
  1803.     15-Aug-91  18:40:10                 No: 94 One Reply
  1804. Sb: #33645-Hungarian
  1805. Fm: Steven E. Patamia 72310,3627
  1806. To: Brian Richter 76437,736
  1807.    
  1808. Brian,
  1809.        Well, here is a response from someone who is not an old hand at C, but
  1810. who has managed to accomplish some non-trivial work AND who, upon surveying the
  1811. Window's world finds so-called Hungarian notation to be mildly irritating.
  1812.    
  1813.        I should start by conceding that there are plenty of times that the
  1814. media is the message and all I want is a rationale to guide name formation of
  1815. something so that I don't have to agonize over it.  However, if the scope of
  1816. such a name is larger than some locality that I can survey in a glance, then
  1817. even this is less desirable than inventing a more meaningful moniker.
  1818.    
  1819.        Without enumerating all the excellent reasons propounded, let me just
  1820. generally agree with the proposed reasons why this notation is obsolete and add
  1821. a final observation.  If I have to expend intellectual effort in name
  1822. formation, I'd much rather invest in creating an evocative name than in
  1823. adhering to some convention whose main goal is simply to highlight aspects of a
  1824. variable I'm trying hard not to have to concentrate on in the first place.
  1825.    
  1826. SEP
  1827.  
  1828.  
  1829.  
  1830. #: 33722 S5/C++ Study Group            orig=PgUp next=     prev=
  1831.     16-Aug-91  18:01:15                 No: 95 One Reply
  1832. Sb: #33660-Hungarian
  1833. Fm: Brian Richter 76437,736
  1834. To: Steven E. Patamia 72310,3627
  1835.    
  1836. I found my excursion into the Windows world so irritating that I couldn't be
  1837. sure whether it was HN or the API in general that was worse.  HN was a habit
  1838. that I picked up from Windows, and I just assumed Petzold wouldn't lie to me. 
  1839. I even at one point started adopting some of the spacing he uses in his book. 
  1840. Then suddenly I looked at my programs and said "Geez, this looks ugly!"  I
  1841. actually edited all the modules in my program to return to more "normal"
  1842. spacings.
  1843.    
  1844. I never thought about your last reason, but I do think it makes sense.  In a
  1845. sense, I think you're saying that HN overemphasizes the use of the type in a
  1846. name, and that there are other more important things that a name should convey.
  1847. It tends to make one almost lazy and not have to think of decent variable
  1848. names.
  1849.    
  1850. In one important project that I was doing with someone else, we'd actually
  1851. spend a half hour or an hour just coming up with the appropriate names for
  1852. certain data structures.  When we did so, the effort paid off tremendously,
  1853. because it made the entire program more readable.  As I look back, I agree that
  1854. these names are far better than anything HN could have provided.
  1855.    
  1856.                                        Brian
  1857.  
  1858.  
  1859.  
  1860. #: 33812 S5/C++ Study Group            orig=PgUp next=     prev=
  1861.     18-Aug-91  13:56:27                 No: 96 One Reply
  1862. Sb: #33722-#Hungarian
  1863. Fm: Steven E. Patamia 72310,3627
  1864. To: Brian Richter 76437,736 (X)
  1865.    
  1866. Brian,
  1867.        Yes I think we agree completely.  What the HN did was mitigate a
  1868. weakness that is possibly obviate by more contemporary thinking.  I'm thinking
  1869. of the logical extremes of HN in the context of "Object Orientation".
  1870.    
  1871.        Think about C++ Classes (something I'm forced to do a lot lately). In
  1872. the tradition of HN, how should you name a class object?  Its a question that
  1873. instantly points up the absurdity of the idea!  One names "objects" to convey
  1874. the essence of what they "represent".  Not only that, but what sense does it
  1875. make to name a class object to match its "type" -- there being as many "types"
  1876. as you are willing to invent!  Now think backwards a little. Every data
  1877. "object" whether a user-defined class or not is nonetheless an "object" if we
  1878. are oriented that way.  In that context, why should we be naming these simpler
  1879. objects in such an arcane way when naming more complex or abstract ones is
  1880. obviously inappropriate?
  1881.    
  1882.        Given type checking and adherence to OOP, HN just melts away as
  1883. irrelevant.
  1884.    
  1885. SEP
  1886.    
  1887.  
  1888.  
  1889.  
  1890. #: 33817 S5/C++ Study Group            orig=PgUp next=     prev=
  1891.     18-Aug-91  16:22:09                 No: 97
  1892. Sb: #33812-Hungarian
  1893. Fm: Brian Richter 76437,736
  1894. To: Steven E. Patamia 72310,3627
  1895.    
  1896. Agreed.  My misgivings about this began when I carried HN right over from C
  1897. into C++.  And the result was very much what you say; it just didn't make much
  1898. sense.
  1899.    
  1900. As an experiment, I've taken that C++ program and partially de-Hungarianized it
  1901. (or performed a Hungarianectomy on it?).  Anyway, results were favorable; the
  1902. program's readability considerably improved.  It just looks clearer and more
  1903. elegant.  And thanks to C++'s strict typing, I don't think there's any danger. 
  1904. The compiler will let you know if you mess up the types of things...
  1905.    
  1906.                                        Brian
  1907.  
  1908.  
  1909.  
  1910. #: 33691 S5/C++ Study Group            orig= 93  next= 103 prev= 94
  1911.     16-Aug-91  10:28:31                 No: 98 Replies 2
  1912. Sb: #33645-Hungarian
  1913. Fm: Karl M. Beem 72311,3467
  1914. To: Brian Richter 76437,736
  1915.    
  1916. Hungarian is wrong. 1) The compiler knows nothing of it. 2) I prefer to
  1917. organize my code so that a single change in a key header file
  1918.    produces a large difference in generated code.  If you used HN and
  1919.    decided to change types, you have to change every instance of the name.
  1920.  
  1921.  
  1922.  
  1923. #: 33716 S5/C++ Study Group            orig=PgUp next=PgDn prev=
  1924.     16-Aug-91  17:33:27                 No: 99
  1925. Sb: #33691-Hungarian
  1926. Fm: Greg Comeau (ComeauComp) 72331,3421
  1927. To: Karl M. Beem 72311,3467
  1928.    
  1929. >If you used HN and decided to change types, you have to change every
  1930. >instance of the name.
  1931.    
  1932. But not only that, but perhaps every instance of a related/copied/assigned/etc
  1933. name from that name.  Tis not simple.
  1934.  
  1935.  
  1936.  
  1937. #: 33724 S5/C++ Study Group            orig= 98  next=     prev=PgUp
  1938.     16-Aug-91  18:01:26                 No: 100 One Reply
  1939. Sb: #33691-Hungarian
  1940. Fm: Brian Richter 76437,736
  1941. To: Karl M. Beem 72311,3467
  1942.    
  1943. I agree with reason 1 but I'm not sure I understand reason 2.  What does the
  1944. fact that a single change in a key header file produces a big difference in
  1945. generated code have to do with HN?
  1946.    
  1947. Not that I'm arguing for HN, but if modules are messing with structure or class
  1948. members directly by their names, they might not be able to silently ignore any
  1949. change in this member's type.  If they're members of a class then it's better
  1950. to use inlined access functions anyway, so the modules don't even have to know
  1951. if they're accessing a member or calling a function or whatever...
  1952.    
  1953.                                        Brian
  1954.  
  1955.  
  1956.  
  1957. #: 33759 S5/C++ Study Group            orig=PgUp next=     prev=
  1958.     17-Aug-91  08:33:34                 No: 101 One Reply
  1959. Sb: #33724-#Hungarian
  1960. Fm: Karl M. Beem 72311,3467
  1961. To: Brian Richter 76437,736 (X)
  1962.    
  1963. If you decide to change iNthings to a long, you would have to change every
  1964. occurrence of the name to lNthings.  Ok, suppose that you do so, in a very
  1965. large function.  Then the compiler tells you that you have 2 lNthings.
  1966. Hopefully, you have a backup.
  1967.    
  1968. Karl
  1969.    
  1970.    
  1971.    
  1972.    
  1973. #: 33770 S5/C++ Study Group            orig=PgUp next=     prev=
  1974.     17-Aug-91  13:53:33                 No: 102
  1975. Sb: #33759-Hungarian
  1976. Fm: Brian Richter 76437,736
  1977. To: Karl M. Beem 72311,3467
  1978.    
  1979. I agree.  Of course, this is true any time you have to change the name of
  1980. something.  I guess the point is that HN gives you another reason to do so
  1981. where you wouldn't have to otherwise...
  1982.    
  1983.                                        Brian
  1984.  
  1985.  
  1986.  
  1987. #: 33694 S5/C++ Study Group            orig= 93  next= 108 prev= 98
  1988.     16-Aug-91  10:58:33                 No: 103 One Reply
  1989. Sb: #33645-Hungarian
  1990. Fm: Greg Comeau (ComeauComp) 72331,3421
  1991. To: Brian Richter 76437,736
  1992.    
  1993. >Changing the type of a variable isn't too much of a problem; it's just a
  1994. >find-and-replace operation.  It's a bit tedious, but doesn't present any
  1995. >special difficulties.
  1996.    
  1997. But that's just my poiny: it *is* a problem.  What about cascading?
  1998. Also, what about a variable name that you've gotten familiar with being
  1999. changed?  Imagine the number of typo's you'd have?  Now, imagine that
  2000. variable name being changed by another team member not telling you about it.
  2001. And of course, imagine the name being changed, and then being reintroduced
  2002. (either replacing the replacer name or in addition to the replacer name) at
  2003. some later date?  Are we having fun yet? ;-)
  2004.  
  2005.  
  2006.  
  2007. #: 33723 S5/C++ Study Group            orig=PgUp next=     prev=
  2008.     16-Aug-91  18:01:21                 No: 104 Replies 2
  2009. Sb: #33694-Hungarian
  2010. Fm: Brian Richter 76437,736
  2011. To: Greg Comeau (ComeauComp) 72331,3421
  2012.    
  2013. Don't think for a moment that I'm trying to argue for HN here, but I don't
  2014. think that's a valid reason.  I'd be a lot worse off if another team member
  2015. changed the type of a variable and *didn't* change the name!  The program would
  2016. link correctly because the linker doesn't know what types the variables are,
  2017. and it would be a very difficult problem to track down.  (I know, it's happened
  2018. to me!)
  2019.    
  2020. Typos are the least of your problems; at least the compiler will catch them for
  2021. you.  Also, I still say find-and-replaces are tedious, but not a problem.  If
  2022. you miss any, the compiler or linker will tell you.
  2023.    
  2024. This doesn't have to do with HN in a sense but equally applies to *any* change
  2025. of a variable name.  One thing I have found is that if a variable has changed
  2026. in function as a program has evolved, it does not pay to be timid about
  2027. renaming it.  The increase in understandability generally seems to outweigh the
  2028. trouble to edit the files to change the name.
  2029.    
  2030. I agree with many of the other arguments against HN, but I think that "because
  2031. it's a lot of trouble to change the name" is a very weak reason...
  2032.    
  2033.                                        Brian
  2034.  
  2035.  
  2036.  
  2037. #: 33733 S5/C++ Study Group            orig=PgUp next= 107 prev=
  2038.     16-Aug-91  19:15:37                 No: 105 One Reply
  2039. Sb: #33723-Hungarian
  2040. Fm: John M. Dlugosz 70007,4657
  2041. To: Brian Richter 76437,736
  2042.    
  2043. If I change something, I _will_ rename it.  That will make sure I don't have
  2044. any old uses sneeking in.
  2045.  
  2046.  
  2047.  
  2048. #: 33771 S5/C++ Study Group            orig=PgUp next=     prev=
  2049.     17-Aug-91  13:53:37                 No: 106
  2050. Sb: #33733-Hungarian
  2051. Fm: Brian Richter 76437,736
  2052. To: John M. Dlugosz 70007,4657
  2053.    
  2054. I do too.  Sometimes I've even had one variable using a somewhat illogical name
  2055. that I really wanted to use for a different variable.  In that case I'd first
  2056. rename the variable whose name I wanted to steal to something different.  Then
  2057. I'd make sure it compiles and runs OK.  Next, I'd rename the second variable to
  2058. the old name of the first variable.
  2059.    
  2060.                                        Brian
  2061.  
  2062.  
  2063.  
  2064. #: 33742 S5/C++ Study Group            orig= 104 next=     prev= 105
  2065.     16-Aug-91  23:03:42                 No: 107
  2066. Sb: #33723-Hungarian
  2067. Fm: Greg Comeau (ComeauComp) 72331,3421
  2068. To: Brian Richter 76437,736 (X)
  2069.    
  2070. >I agree with many of the other arguments against HN, but I think that "because
  2071. >it's a lot of trouble to change the name" is a very weak reason...
  2072.    
  2073. I won't argue this to my death, but I will say that even if I agreed, it's
  2074. just one argument in a whole bunch, and hence weak or not, it's still a
  2075. minus.
  2076.  
  2077.  
  2078.  
  2079. #: 33698 S5/C++ Study Group            orig= 93  next=     prev= 103
  2080.     16-Aug-91  11:32:04                 No: 108 Replies 2
  2081. Sb: #33645-Hungarian
  2082. Fm: Pete Becker (Borland) 76117,3675
  2083. To: Brian Richter 76437,736
  2084.    
  2085. Brian,
  2086.        If someone doesn't know the type of a variable named numBytes, why are
  2087. they using it?  Hmm, probably because they're hacking the code instead of
  2088. thinking about it.
  2089.        -- Pete
  2090.  
  2091.  
  2092.  
  2093. #: 33707 S5/C++ Study Group            orig=PgUp next= 112 prev=
  2094.     16-Aug-91  17:03:39                 No: 109 One Reply
  2095. Sb: #33698-Hungarian
  2096. Fm: John M. Dlugosz 70007,4657
  2097. To: Pete Becker (Borland) 76117,3675
  2098.    
  2099.     If someone doesn't know the type of a variable named numBytes, why are
  2100.  they using it?
  2101.  ^^^^
  2102. error on line 2: disagreement in number with anteceedent
  2103.    
  2104. Don't you _hate_ strong type checking?  <g>  Perhaps english should not tag
  2105. words with attributes such as number and tense.  Or the rules should be made
  2106. more uniform.  Better yet, remove pronouns entirely.  That is just a pointer,
  2107. and you know how pointers can get you in trouble!
  2108.    
  2109. --John
  2110.  
  2111.  
  2112.  
  2113. #: 33781 S5/C++ Study Group            orig=PgUp next=     prev=
  2114.     17-Aug-91  15:02:45                 No: 110 One Reply
  2115. Sb: #33707-Hungarian
  2116. Fm: Rudyard Merriam 76234,2561
  2117. To: John M. Dlugosz 70007,4657
  2118.    
  2119. John
  2120.    
  2121. You need to upgrade your English checker. The use of 'they' in situations where
  2122. he/she should technically appear is becoming accepted usage.
  2123.    
  2124. Rud
  2125.  
  2126.  
  2127.  
  2128. #: 33908 S5/C++ Study Group            orig=PgUp next=     prev=
  2129.     20-Aug-91  10:29:24                 No: 111
  2130. Sb: #33781-Hungarian
  2131. Fm: Skip Key 73130,2102
  2132. To: Rudyard Merriam 76234,2561
  2133.    
  2134. My mother the English teacher would shoot you<g>.
  2135.  
  2136.  
  2137.  
  2138.  
  2139. #: 33725 S5/C++ Study Group            orig= 108 next=     prev= 109
  2140.     16-Aug-91  18:01:30                 No: 112 One Reply
  2141. Sb: #33698-Hungarian
  2142. Fm: Brian Richter 76437,736
  2143. To: Pete Becker (Borland) 76117,3675
  2144.    
  2145. Excellent point, and I knew somebody was going to say that.  I agree that if
  2146. it's so important for somebody to constantly be reminded of the types of
  2147. variables, it's because they don't really know what they're doing.  People
  2148. should not use variables without knowing their type...
  2149.    
  2150.                                        Brian
  2151.  
  2152.  
  2153.  
  2154. #: 33737 S5/C++ Study Group            orig=PgUp next=     prev=
  2155.     16-Aug-91  21:13:48                 No: 113 Replies 3
  2156. Sb: #33725-Hungarian
  2157. Fm: phil hystad 73260,114
  2158. To: Brian Richter 76437,736
  2159.    
  2160. >...People should not use variables without knowing their type...
  2161.    
  2162. Now, I do agree with that statement; however, to be typeless without problems
  2163. is bliss.  I program quite a bit in Smalltalk, just for fun. And, Smalltalk
  2164. does not have types (in the traditional sense).  Since it is  a pure object
  2165. oriented system, and since it is interpretive (late binding), type is not as
  2166. important since the actual instructions and logic executed is determined at run
  2167. time.  Though this is not as efficient as compiled code but it is nicer knowing
  2168. that I don't have to worry about type and everything works hunky-dory anyway.
  2169.    
  2170.        phil
  2171.  
  2172.  
  2173.  
  2174. #: 33746 S5/C++ Study Group            orig=PgUp next= 118 prev=
  2175.     16-Aug-91  23:40:27                 No: 114 One Reply
  2176. Sb: #33737-#Hungarian
  2177. Fm: Greg Comeau (ComeauComp) 72331,3421
  2178. To: phil hystad 73260,114 (X)
  2179.    
  2180. >[In Smalltalk] type is not as important since the actual instructions and
  2181. >logic executed is determined at run time.
  2182.    
  2183. No.
  2184.    
  2185. >it is nicer knowing that I don't have to worry about type
  2186.    
  2187. Well, it's certainly easier to prototype with.
  2188.    
  2189. >and everything works hunky-dory anyway.
  2190.    
  2191. No (like above).
  2192.    
  2193.    
  2194.  
  2195.  
  2196.  
  2197. #: 33752 S5/C++ Study Group            orig=PgUp next=     prev=
  2198.     17-Aug-91  00:59:41                 No: 115 One Reply
  2199. Sb: #33746-Hungarian
  2200. Fm: phil hystad 73260,114
  2201. To: Greg Comeau (ComeauComp) 72331,3421
  2202.    
  2203. Greg...
  2204.    
  2205. Quit cryptic responses...but, as ever, your comments lose a lot of meaning in
  2206. translation (or is that compilation).
  2207.    
  2208.        phil
  2209.  
  2210.  
  2211.  
  2212. #: 33808 S5/C++ Study Group            orig=PgUp next=     prev=
  2213.     18-Aug-91  11:48:51                 No: 116 One Reply
  2214. Sb: #33752-Hungarian
  2215. Fm: Greg Comeau (ComeauComp) 72331,3421
  2216. To: phil hystad 73260,114
  2217.    
  2218. >Quit cryptic responses...but, as ever, your comments lose a lot of meaning in
  2219. >translation (or is that compilation).
  2220.    
  2221. Sorry, but that's just about the magnitude of the way things gotta be as my
  2222. multi-tasker only allow a max of 50 processes.  Anyway, *please* ask me about
  2223. anything I've said that doesn't make sense, is cryptic, or is ambiguous etc.
  2224.  
  2225.  
  2226.  
  2227. #: 33809 S5/C++ Study Group            orig=PgUp next=     prev=
  2228.     18-Aug-91  12:33:12                 No: 117
  2229. Sb: #33808-Hungarian
  2230. Fm: phil hystad 73260,114
  2231. To: Greg Comeau (ComeauComp) 72331,3421
  2232.    
  2233. Greg...
  2234.    
  2235. My comment on your cryptic-ness was with respect to your terse "yes" and "no"
  2236. answers without explanation.  I believe that only God can say "Yes" and "no"
  2237. without justification or explanation.  However, so be it for now. I am off to
  2238. London in just a few hours and the thread is likely to be terminated (boy, I
  2239. still have to see Terminator 2) before I get back.
  2240.    
  2241.        phil
  2242.  
  2243.  
  2244.  
  2245. #: 33749 S5/C++ Study Group            orig= 113 next=PgDn prev= 114
  2246.     17-Aug-91  00:05:56                 No: 118
  2247. Sb: #33737-Hungarian
  2248. Fm: Ben Sano 72401,2736
  2249. To: phil hystad 73260,114 (X)
  2250.    
  2251. phil
  2252.  >to be typeless without problems is bliss.
  2253.    
  2254. BLISS is typeless but Smalltalk is dynamicly typed <g>
  2255.    
  2256. --Ben
  2257.  
  2258.  
  2259.  
  2260. #: 33763 S5/C++ Study Group            orig= 113 next=     prev=PgUp
  2261.     17-Aug-91  11:24:11                 No: 119 Replies 2
  2262. Sb: #33737-#Hungarian
  2263. Fm: Pete Becker (Borland) 76117,3675
  2264. To: phil hystad 73260,114 (X)
  2265.    
  2266. Phil,
  2267.        Smalltalk has strong type checking.  It just does it later...
  2268.        -- Pete (paraphrased from Peter Deutsch)
  2269.    
  2270.    
  2271.    
  2272.  
  2273. #: 33765 S5/C++ Study Group            orig=PgUp next=PgDn prev=
  2274.     17-Aug-91  11:55:27                 No: 120
  2275. Sb: #33763-Hungarian
  2276. Fm: phil hystad 73260,114
  2277. To: Pete Becker (Borland) 76117,3675
  2278.    
  2279. Pete...
  2280.    
  2281. Actually, all pure object oriented programming languages have strong type
  2282. checking...but, they do take the burden off the programmer and put it in the
  2283. binding at runtime.  This was the point I was trying to make though it was not
  2284. clear as I re-read my message.
  2285.    
  2286. Regarding the Hungarian notation, I used with with Windows programming because
  2287. it was so prevalent...but, in my opinion, notation on the identifier name that
  2288. declares its type should be un-necessary.
  2289.    
  2290.        phil
  2291.  
  2292.  
  2293.  
  2294. #: 33839 S5/C++ Study Group            orig= 119 next=     prev=PgUp
  2295.     19-Aug-91  14:44:09                 No: 121
  2296. Sb: #33763-Hungarian
  2297. Fm: Greg Comeau (ComeauComp) 72331,3421
  2298. To: Pete Becker (Borland) 76117,3675
  2299.    
  2300. >       Smalltalk has strong type checking.  It just does it later...
  2301. >       -- Pete (paraphrased from Peter Deutsch)
  2302.    
  2303. Well, I'll strongly disagree with that.
  2304.    
  2305. Is there any type checking in Smalltalk?  Yes.  Is it strong?  No.
  2306.  
  2307.  
  2308.  
  2309. #: 33649 S5/C++ Study Group            orig= 28  next= 125 prev= 93
  2310.     15-Aug-91  12:51:49                 No: 122 One Reply
  2311. Sb: #33623-Hungarian
  2312. Fm: RUSSELL MORE 70242,3546
  2313. To: Greg Comeau (ComeauComp) 72331,3421
  2314.    
  2315.    
  2316.    
  2317. Hungarian notation drives me nuts and for me personally, destroys the
  2318. readability of the code... with ANSI C and a good lint program (or high
  2319. warning levels on some compilers) I get all the type restraints I need.
  2320.  
  2321.  
  2322.  
  2323. #: 33661 S5/C++ Study Group            orig=PgUp next=     prev=
  2324.     15-Aug-91  19:18:34                 No: 123 One Reply
  2325. Sb: #33649-Hungarian
  2326. Fm: Tom Bernhardt 76646,126
  2327. To: RUSSELL MORE 70242,3546
  2328.    
  2329. Hungarian is far worse than that.  It is: a. inherently inconsistant (many
  2330. dialects/variations due to the vast number of type/attribute combinations). b.
  2331. Only minimally useful for very large functions that should not exist anyway. c.
  2332. pedantic and insipid (necessitates provision of lots of unimportant/obvious
  2333. information at the expense of all-important readability). d. a source of
  2334. maintenance and portability problems (why should I change the name of an
  2335. identifier when the application dictates that it increase from a short to a
  2336. long, i.e., why not use application type prefixes such as numEmployees instead
  2337. of CPU/language types).  This is tremendously magnified with the shift to OO
  2338. and C++.  Does 'x' in 'void f(short &x)' get a p(pointer) prefix or not? e. an
  2339. insult to a country already beleaguered by over forty years of communist
  2340. oppression. f. legal proof of psychosis or previously undetected congenital
  2341. anencephalism.
  2342.    
  2343. Hungarian notation is bad enough in C.  Let's grow up and completely lose in
  2344. with C++.
  2345.  
  2346.  
  2347.  
  2348. #: 33726 S5/C++ Study Group            orig=PgUp next=     prev=
  2349.     16-Aug-91  18:01:37                 No: 124
  2350. Sb: #33661-Hungarian
  2351. Fm: Brian Richter 76437,736
  2352. To: Tom Bernhardt 76646,126
  2353.    
  2354. An impressive list of reasons, most of which I would agree with.  (a) is an
  2355. excellent reason, especially in C++!  (b) and (c) are good reasons also.
  2356. Despite my apparent arguments to the contrary, I'd have to agree with (d). I
  2357. don't agree that it's serious within a single program if you have to change the
  2358. names as you write it, but as far as maintenance and portability I must agree. 
  2359. If you have a completed program that you modify in the future you don't want to
  2360. go messing with modules that otherwise could remain unedited, just to change
  2361. the names.  (BTW, 'x' in 'void f(short &x)' would not get a 'p' prefix; a
  2362. reference is not a pointer.)  I agree with (e); if the guy only had a name that
  2363. was easier for us to remember, only one guy need be insulted instead of a whole
  2364. country <g>.
  2365.    
  2366. The only one I'd hesitate to agree with is (f).  After all, people actually
  2367. join the Church of Scientology (including one guy that was going to be my
  2368. boss!).  From what I hear, even some actually intelligent people.  So if people
  2369. can have their minds so twisted around against their will, then certainly a
  2370. programmer can be excused for adopting a practice from the leading book on
  2371. Windows programming.  I speak from experience on this.  But in C++ HN just
  2372. didn't look right!  And everyone's opinion has certainly confirmed this
  2373. suspicion...
  2374.    
  2375.                                        Brian
  2376.  
  2377.  
  2378.  
  2379. #: 33813 S5/C++ Study Group            orig= 28  next=     prev= 122
  2380.     18-Aug-91  14:43:17                 No: 125 Replies 2
  2381. Sb: #33623-#Hungarian
  2382. Fm: Howard L Howell 70703,762
  2383. To: Greg Comeau (ComeauComp) 72331,3421
  2384.    
  2385. Hello, all,
  2386.    
  2387.         Couldn't avoid putting in my two cents worth...
  2388.         If you use Hunk... Then you must also use it on functions...
  2389.         Therefore, you no longer have complete freedom in function names
  2390. because you may obscurely name something in such a way that the function name
  2391. overlaps a hugarian declarative....
  2392.         Worse, the returned value may be inadvertantly retyped possibly without
  2393. correct reconstruction unless your return code (low-level) or your compiler can
  2394. detect the return type at run or compile time respectively....
  2395.         So... Now you have a dual edit problem... if you rename a variable, you
  2396. must be sure that it doesn't overlap a function, and if you rename a function
  2397. you must be sure that it doesn't overlap your hungarian naming conventions...
  2398. Not to mention possible runtime or compiler overhead.
  2399.    
  2400. ;-) Les H.
  2401.    
  2402.    
  2403.  
  2404.  
  2405. #: 33818 S5/C++ Study Group            orig=PgUp next=PgDn prev=
  2406.     18-Aug-91  16:22:13                 No: 126
  2407. Sb: #33813-Hungarian
  2408. Fm: Brian Richter 76437,736
  2409. To: Howard L Howell 70703,762
  2410.    
  2411. That was the second reason I didn't like HN.  (The first had to do with overall
  2412. crypticness because of separate abbreviations for each class.)  It got carried
  2413. over from a C program into C++, and it did strike me as very inconsistent to
  2414. use HN for the variables and not for the functions.  And using it for the
  2415. functions was absurd because chances were pretty good the names were going to
  2416. overlap, or at best be confusing.  To really do it for a function, you'd have
  2417. to put in the return value and the types of its arguments, I suppose.  IOW
  2418. you'd get one of those C++ mangled function names, which is definitely
  2419. something that the programmer should never have to deal with!
  2420.    
  2421. Despite this, it definitely surprised me how many people had opinions, and also
  2422. that they were all the same.  Thanks for your input...this entire discussion
  2423. has been very enlightening...
  2424.    
  2425.                                        Brian
  2426.  
  2427.  
  2428.  
  2429. #: 33860 S5/C++ Study Group            orig= 125 next=     prev=PgUp
  2430.     19-Aug-91  16:30:32                 No: 127
  2431. Sb: #33813-Hungarian
  2432. Fm: Greg Comeau (ComeauComp) 72331,3421
  2433. To: Howard L Howell 70703,762
  2434.    
  2435. >If you use Hunk... Then you must also use it on functions...
  2436.    
  2437. Yep.
  2438. #: 33658 S5/C++ Study Group            orig=ROOT next= 142 prev= 28
  2439.     15-Aug-91  16:59:20                 No: 128 Replies 2
  2440. Sb: C++ Programming Style
  2441. Fm: Brian Richter 76437,736
  2442. To: John M. Dlugosz 70007,4657
  2443.    
  2444. OK, suppose I did not use Hungarian notation (for the purpose of *this*
  2445. thread).  I would think I'd have to be consistent in the sorts of names I chose
  2446. for things to avoid confusion.
  2447.    
  2448. In my experiments in message "grammar" I commonly ended up using a verb-object
  2449. sort of form, with maybe an occasional adjective or adverb thrown in.  But
  2450. thanks to the magic of overloaded functions in C++, a function is smart enough
  2451. to "know" what type of object you're giving it. Therefore the only thing needed
  2452. in the member function's name should generally be the verb.  (An exception to
  2453. this would be the set/get family of functions which we already discussed;
  2454. they'd have the name of the attribute or data item you're setting or getting.)
  2455.    
  2456. Also, you mentioned the idea of starting member variables with an uppercase
  2457. letter, as opposed to a set/get function associated with it.  Is this how
  2458. member variables can be distinguished from non-member variables?  I would
  2459. assume that "ordinary" variables within a member function would generally be
  2460. all lowercase (or maybe not, this is just a guess on my part).
  2461.    
  2462. And finally, how would one tell constants from variables?  I still put #defines
  2463. (rarer in C++; mostly from bits of C code I occasionally reused) in all caps. 
  2464. Would one want to know, for example, that 'screen_width' is a constant, and not
  2465. a variable?
  2466.    
  2467.                                        Brian
  2468.  
  2469.  
  2470.  
  2471. #: 33666 S5/C++ Study Group            orig=PgUp next= 137 prev=
  2472.     15-Aug-91  20:24:12                 No: 129 Replies 2
  2473. Sb: #33658-C++ Programming Style
  2474. Fm: John M. Dlugosz 70007,4657
  2475. To: Brian Richter 76437,736
  2476.    
  2477. Yes, the names are shorter because they are all verb.  Excellent point.
  2478.    
  2479. I used initial cap for the private variable, and lower case for the access
  2480. function.
  2481.    
  2482.    private:
  2483.       int Xmax;
  2484.    public:
  2485.       int xmax() { return Xmax; }
  2486.    
  2487. it is just a convienence.  It sure beats synonyms!
  2488.    
  2489. I've been using mixed caps or initial caps for Enum values.  I don't have any
  2490. DEFINE's except for TRUE and FALSE.
  2491.    
  2492. Tell constants from variables?  Well, often times many things are const. The
  2493. parameters and variables that are initialized once and used later but never
  2494. changed.  I don't mark them special!  constants are very popular.
  2495.    
  2496. non-member (global) variables are very rare too.  You can generally recognise
  2497. them on sight.  The names can be descriptive too, like main_cursor and
  2498. master_update_zone.  Normally such things are static members though.
  2499.    
  2500. --John
  2501.  
  2502.  
  2503.  
  2504. #: 33717 S5/C++ Study Group            orig=PgUp next= 136 prev=
  2505.     16-Aug-91  17:33:32                 No: 130 One Reply
  2506. Sb: #33666-C++ Programming Style
  2507. Fm: Greg Comeau (ComeauComp) 72331,3421
  2508. To: John M. Dlugosz 70007,4657
  2509.    
  2510. >   private:
  2511. >      int Xmax;
  2512. >   public:
  2513. >      int xmax() { return Xmax; }
  2514.    
  2515. I've been 1/2 ignoring this part of the threads.  So, why would anybody want
  2516. to be doing this?  (This question has nothing to do with the X/x naming, but
  2517. to what benefit you are seeing in this case in your elaborating into using a
  2518. get routine.)
  2519.  
  2520.  
  2521.  
  2522. #: 33734 S5/C++ Study Group            orig=PgUp next=     prev=
  2523.     16-Aug-91  19:15:43                 No: 131 One Reply
  2524. Sb: #33717-C++ Programming Style
  2525. Fm: John M. Dlugosz 70007,4657
  2526. To: Greg Comeau (ComeauComp) 72331,3421 (X)
  2527.    
  2528. Huh?  that is a classic access function.  You can read the value from outside
  2529. the class but not alter it.  It also gives you the flexibily of changing the
  2530. implementation and not breaking any code-- all the uses of xmax is a function
  2531. call and you can reimplement that function rather than having to track down
  2532. every use of the variable and change it to something different.
  2533.  
  2534.  
  2535.  
  2536. #: 33744 S5/C++ Study Group            orig=PgUp next=     prev=
  2537.     16-Aug-91  23:03:54                 No: 132 One Reply
  2538. Sb: #33734-C++ Programming Style
  2539. Fm: Greg Comeau (ComeauComp) 72331,3421
  2540. To: John M. Dlugosz 70007,4657
  2541.    
  2542. >Huh?  that is a classic access function.  You can read the value from outside
  2543. >the class but not alter it.  It also gives you the flexibily of changing the
  2544. >implementation and not breaking any code-- all the uses of xmax is a function
  2545. >call and you can reimplement that function rather than having to track down
  2546. >every use of the variable and change it to something different.
  2547.    
  2548. Um, I suppose I worded my question wrong.  I've seen the idiom countless
  2549. times and realize its reason, but I've always considered the reason more of a
  2550. pretext in many cases as I've just seen all this set/get stuff carried way
  2551. too far IMO in the name of encapsulation.
  2552.  
  2553.  
  2554.  
  2555. #: 33789 S5/C++ Study Group            orig=PgUp next=     prev=
  2556.     17-Aug-91  15:18:51                 No: 133 One Reply
  2557. Sb: #33744-C++ Programming Style
  2558. Fm: John M. Dlugosz 70007,4657
  2559. To: Greg Comeau (ComeauComp) 72331,3421
  2560.    
  2561. Well, it was a trivial example.  In my library, I just make FPen public and let
  2562. people set it or read it.  Silly to have access function for that. But the
  2563. display resolution, OTOH, is read-only public so I need the function. If C++
  2564. had a mechanism for re-specifing access as public but const than it would find
  2565. uses here.  Meanwhile, good old inlines will do.
  2566.    
  2567. --John
  2568.  
  2569.  
  2570.  
  2571. #: 33841 S5/C++ Study Group            orig=PgUp next=     prev=
  2572.     19-Aug-91  14:44:21                 No: 134 One Reply
  2573. Sb: #33789-C++ Programming Style
  2574. Fm: Greg Comeau (ComeauComp) 72331,3421
  2575. To: John M. Dlugosz 70007,4657
  2576.    
  2577. >Well, it was a trivial example.  In my library, I just make FPen public and
  2578. >let people set it or read it.  Silly to have access function for that. But the
  2579. >display resolution, OTOH, is read-only public so I need the function. If C++
  2580. >had a mechanism for re-specifing access as public but const than it would find
  2581. >uses here.  Meanwhile, good old inlines will do.
  2582.    
  2583. That I agree with.  Note though that although I suspect at this point in time
  2584. that inline's are and will continue to be the most efficient mechanism, however
  2585. note there are 'public: const T &'s that could be used and effortlessly
  2586. initialized via constructor member-initializer syntax.
  2587.  
  2588.  
  2589.  
  2590. #: 33869 S5/C++ Study Group            orig=PgUp next=     prev=
  2591.     19-Aug-91  17:45:22                 No: 135
  2592. Sb: #33841-C++ Programming Style
  2593. Fm: John M. Dlugosz 70007,4657
  2594. To: Greg Comeau (ComeauComp) 72331,3421
  2595.    
  2596. Yes, I use const members too.  Most people never think of it I'm sure!
  2597.    
  2598. But there are cases where I'll want to change things inside and have read only
  2599. outside.
  2600.    
  2601. Having a public-const ability would just be syntactic sugar.  Easy enough to
  2602. add, but that is the problem:  you can do without now, so they won't touch it
  2603. for years.
  2604.    
  2605. --John
  2606.  
  2607.  
  2608.  
  2609. #: 33728 S5/C++ Study Group            orig= 129 next=     prev= 130
  2610.     16-Aug-91  18:01:47                 No: 136
  2611. Sb: #33666-C++ Programming Style
  2612. Fm: Brian Richter 76437,736
  2613. To: John M. Dlugosz 70007,4657
  2614.    
  2615. I can't help but be reminded of the famous Hofstadter sentence, "This sentence
  2616. no verb."
  2617.    
  2618. After I wrote my message I started to think about constants and variables. (I
  2619. find it sometimes leads to more interesting conversations if I think about my
  2620. messages *after* I write them, instead of before. <g>)  I was reminded of good
  2621. old MASM (not that I like that syntax!).  At first it had occurred to me that
  2622. if you see "mov al,screen_width" you don't know if 'screen_width' is a constant
  2623. equate or a variable.  Then I realized that perhaps that's good.  You can later
  2624. make 'screen_width' into a variable without changing your code!  So constancy
  2625. ought perhaps to be far more temporary than #defines would have had one
  2626. believe.  I can think of several constants in one of my programs right now that
  2627. may become variables with future enhancements.
  2628.    
  2629. Non-member global variables are indeed rare in C++, and the rarer the better. 
  2630. Actually what I really meant by "non-member" was those temporary variables
  2631. inside a member function...
  2632.    
  2633.                                        Brian
  2634.  
  2635.  
  2636.  
  2637. #: 33683 S5/C++ Study Group            orig= 128 next=     prev= 129
  2638.     16-Aug-91  02:03:53                 No: 137 One Reply
  2639. Sb: #33658-C++ Programming Style
  2640. Fm: Don E. Groves, Jr. 71310,3702
  2641. To: Brian Richter 76437,736
  2642.    
  2643. Brain,
  2644. Would one want to know, for example, that 'screen_width' is a constant, and not
  2645. a variable?
  2646.    
  2647.   YES, because 'screen_width' should never be a CONSTANT.
  2648.     {thats a 'sore spot' waiting to surface.}
  2649. Jr..
  2650.  
  2651.  
  2652.  
  2653. #: 33727 S5/C++ Study Group            orig=PgUp next=     prev=
  2654.     16-Aug-91  18:01:40                 No: 138 One Reply
  2655. Sb: #33683-C++ Programming Style
  2656. Fm: Brian Richter 76437,736
  2657. To: Don E. Groves, Jr. 71310,3702
  2658.    
  2659. Sorry, bad example.  Of course you're right.  'screen_height' is the one you'd
  2660. want even less to be a constant...
  2661.    
  2662.                                        Brian
  2663.  
  2664.  
  2665.  
  2666. #: 33890 S5/C++ Study Group            orig=PgUp next=     prev=
  2667.     19-Aug-91  22:30:04                 No: 139 Replies 2
  2668. Sb: #33727-C++ Programming Style
  2669. Fm: Don E. Groves, Jr. 71310,3702
  2670. To: Brian Richter 76437,736
  2671.    
  2672. Brian,
  2673.   Didn't mean to sound so Turse about.
  2674.     { assuming screen Width a CONSTANT }
  2675. Note: Even QuarterDeck Office System did it in DESQVIEW.
  2676. Which is HARD-CODED to an 80 character wide screen.
  2677.    Bring it up in a Oversize Screen setup and the main menu winds up all out of
  2678. shape. { somebody tried to save a few bits of code <G> }
  2679. Jr..
  2680.  
  2681.  
  2682.  
  2683. #: 33898 S5/C++ Study Group            orig=PgUp next=PgDn prev=
  2684.     20-Aug-91  00:26:05                 No: 140
  2685. Sb: #33890-C++ Programming Style
  2686. Fm: John M. Dlugosz 70007,4657
  2687. To: Don E. Groves, Jr. 71310,3702
  2688.    
  2689. Mine did not work at all if the screen was in 90 col mode (herc plus).  Have
  2690. not figured that one out.  I got a highlight bar but no visible text!
  2691.    
  2692. putting it in 90 col mode while running makes the monitor desync when changing
  2693. screens.
  2694.    
  2695. A while back, discussion turned to the 80 col hardcode in Borland's IDE. The
  2696. reason given was "speed".  We figured out that the fastest way to do screen
  2697. lookups was with an array of line offsets, which allows variable widths!  So
  2698. much for that excuse.  Meanwhile, I used variable col on my first code on a
  2699. 4.77 Mhz PC and did not find it too slow (it _is_ a hundred clocks more to do a
  2700. multiply, but I never thought about it).  So I did not like the answer anyway.
  2701.    
  2702. --John
  2703.  
  2704.  
  2705.  
  2706. #: 33913 S5/C++ Study Group            orig= 139 next=     prev=PgUp
  2707.     20-Aug-91  11:54:03                 No: 141
  2708. Sb: #33890-C++ Programming Style
  2709. Fm: Brian Richter 76437,736
  2710. To: Don E. Groves, Jr. 71310,3702
  2711.    
  2712. I did it too, in my last project, but there was good reason then.  The entire
  2713. screen layout was designed around 80 columns.  By definition, things had to be
  2714. certain widths, so there was no advantage in having more columns. Screen height
  2715. is the thing you *really* don't want to be a constant; it's really common to
  2716. want to change the height, I think...
  2717.    
  2718.                                        Brian
  2719.  
  2720.  
  2721.  
  2722. #: 33772 S5/C++ Study Group            orig=ROOT next=     prev= 128
  2723.     17-Aug-91  13:53:43                 No: 142 One Reply
  2724. Sb: #Hungarian
  2725. Fm: Brian Richter 76437,736
  2726. To: All
  2727.    
  2728. Right from the horse's mouth...
  2729.    
  2730. *******************************
  2731.    
  2732. That's kind of an odd expression, when you think about it.  I just used it here
  2733. as a sort of cheap attention-getting device.  Anyway, during this discussion, I
  2734. thought, "Gee, if only I could talk to the creator of this notation and find
  2735. out why *he* likes it."  As it turned out, someone already beat me to it, and
  2736. the result was sitting on my bookshelves in a book called "Programmers at
  2737. Work".  The very first chapter was an interview with Charles Simonyi, and he's
  2738. the guy.
  2739.    
  2740. Essentially his argument was that the names are the greatest bulk of a program,
  2741. so that's the part to improve.  To do so, the properties of a variable actually
  2742. become part of the name.  (It surprised me a bit here that he did not say the
  2743. "type", but apparently variable types are not really the essence of HN.)  Then
  2744. he argues that readability as far as reading the names out loud is not
  2745. important because you don't go up to a podium and read a program.  He says the
  2746. association between the name and the properties is important in increasing
  2747. comprehension.  Also, apparently "Hungarian" is a joke; people found the
  2748. notation cryptic and said it must be Hungarian.  And I had thought it was
  2749. because people couldn't remember his name...
  2750.    
  2751.    
  2752. [More]
  2753.    
  2754.    
  2755.    
  2756.    
  2757.    
  2758.  
  2759.  
  2760.  
  2761. #: 33773 S5/C++ Study Group            orig=PgUp next=     prev=
  2762.     17-Aug-91  13:53:49                 No: 143 Replies 2
  2763. Sb: #33772-Hungarian
  2764. Fm: Brian Richter 76437,736
  2765. To: Brian Richter 76437,736
  2766.    
  2767. [Continued]
  2768.    
  2769. Anyway, the book gave an example of "Hungarian" code taken from MS Word. The
  2770. name "vbchrMac" is translated as follows:
  2771.    
  2772. The variable is global (v), current maximum pointing one beyond the last
  2773. element (Mac) based pointer to a group (b) of chr structures. The name chr has
  2774. further meaning:  character run, which is specific to Word.
  2775.    
  2776. For those of you who are "use-mention" fanatics, I just copied that paragraph
  2777. right out of the book, so don't blame me for the lack of appropriate quotes.
  2778.    
  2779. In any case, this is more extreme than anything I've seen, even in Windows. And
  2780. honestly, I don't really care for it.  It still doesn't tell me what group of
  2781. "chr" structures it points at or give me a hint as to why I need such a
  2782. variable in the first place.  It could even be that this is what some of you
  2783. were thinking of as HN, and in that case I'd have to agree...
  2784.    
  2785.                                        Brian
  2786.  
  2787.  
  2788.  
  2789. #: 33790 S5/C++ Study Group            orig=PgUp next= 150 prev=
  2790.     17-Aug-91  16:08:21                 No: 144 One Reply
  2791. Sb: #33773-#Hungarian
  2792. Fm: Rudyard Merriam 76234,2561
  2793. To: Brian Richter 76437,736 (X)
  2794.    
  2795. Brian
  2796.    
  2797. I tried to creat a name that I would use for that "vbchrMac" and I couldn't
  2798. even figure enough of what it did!. The best I got was "Cur...Ptr" or maybe
  2799. "Nxt...Ptr" but whatever is supposed to be where the "..." is totally eluded
  2800. me. Maybe I'd add "Gbl" to the fron but I don't usually have global vars so
  2801. that isn't normally a critical distinction. But I really find 'v' to be
  2802. mnemonic for global <s>.
  2803.    
  2804. After another look I guess the name would be "NxtChRunBPtr".
  2805.    
  2806. Rud
  2807.    
  2808.    
  2809.    
  2810.    
  2811. #: 33795 S5/C++ Study Group            orig=PgUp next=     prev=
  2812.     17-Aug-91  17:32:45                 No: 145 Replies 2
  2813. Sb: #33790-Hungarian
  2814. Fm: Brian Richter 76437,736
  2815. To: Rudyard Merriam 76234,2561
  2816.    
  2817. Looking at the code fragment on that page that uses it is still no help in
  2818. figuring out what that variable does.  Although there's a lot of information in
  2819. that name, I think something's still missing.  Your name makes more sense to
  2820. me.  I can just look at it and say to myself "next character run based
  2821. pointer".  Despite his point that you don't read code aloud, with HN you have
  2822. to translate it to yourself.  Given "vbchrMac" and that I knew the code, I'd
  2823. look at it and say, "uh, global based character run mac" (assuming that you
  2824. further remember what "Mac" means).  As I scan the code, I have to keep
  2825. performing this translation process every time I read it.  So to me, the code
  2826. is very hard to read.
  2827.    
  2828. Maybe to the programmer it's less confusing, but code will generally have to be
  2829. read by someone else too.
  2830.    
  2831.                                        Brian
  2832.  
  2833.  
  2834.  
  2835. #: 33816 S5/C++ Study Group            orig=PgUp next= 148 prev=
  2836.     18-Aug-91  15:27:56                 No: 146 One Reply
  2837. Sb: #33795-#Hungarian
  2838. Fm: Rudyard Merriam 76234,2561
  2839. To: Brian Richter 76437,736 (X)
  2840.    
  2841. Brian
  2842.    
  2843. Reading that "vbchrMac" reminds me of working in Fortran and later in Forth.
  2844. Fortran because it had the 6 char limit on variable names so you wound up with
  2845. a lot of "ICN" for an "integer customer number". Then the Forthians tended to
  2846. be cryptic with their word names.
  2847.    
  2848. Rud
  2849.    
  2850.    
  2851.    
  2852.    
  2853. #: 33819 S5/C++ Study Group            orig=PgUp next=     prev=
  2854.     18-Aug-91  16:22:18                 No: 147
  2855. Sb: #33816-Hungarian
  2856. Fm: Brian Richter 76437,736
  2857. To: Rudyard Merriam 76234,2561
  2858.    
  2859. I remember FORTRAN.  Never used Forth.  It reminds me of a couple of recent
  2860. assembly language programs I had to upgrade.  They were done on an ancient
  2861. development system that only allowed 6 character symbol names.  As a result
  2862. many of them were unavoidable cryptic; most were acronyms.  We ported the
  2863. source code over to a PC, and got an assembler that supported 32-character
  2864. names.  Once I puzzled through it to figure out what they did, I actually found
  2865. it worthwhile to edit all the modules to rename the variables and subroutines
  2866. to reflect what they really did.  This was a lot of work, but the change proved
  2867. to be simple once that was done, and it actually worked the first time!
  2868.    
  2869.                                        Brian
  2870.  
  2871.  
  2872.  
  2873. #: 33851 S5/C++ Study Group            orig= 145 next=     prev= 146
  2874.     19-Aug-91  14:45:03                 No: 148 One Reply
  2875. Sb: #33795-Hungarian
  2876. Fm: Greg Comeau (ComeauComp) 72331,3421
  2877. To: Brian Richter 76437,736
  2878.    
  2879. Besides seeing that its hard to read, it's not clear to me why chr is
  2880. lowercase?  What if chr had encodings in it?  For instance, what if chr was
  2881. called bchr?  What's he limited now is even the though behind the "normal" part
  2882. of the name.  And yes, although he's right about not uttering program's at
  2883. podium's, he is wrong in the sense that it is often a consideration for the
  2884. telephone, and furthermore, unless one is not intimate with a given name, one
  2885. most certain has to stop to figure it out (since of course, figuring it out
  2886. *is* part of the premise of HN).
  2887.  
  2888.  
  2889.  
  2890. #: 33874 S5/C++ Study Group            orig=PgUp next=     prev=
  2891.     19-Aug-91  17:51:18                 No: 149
  2892. Sb: #33851-Hungarian
  2893. Fm: Brian Richter 76437,736
  2894. To: Greg Comeau (ComeauComp) 72331,3421
  2895.    
  2896. I think he's wrong about reading a name, because even when I read my own code I
  2897. do read it to myself, in a sense.  Certainly you do sometimes say a name to
  2898. yourself as you think of it, and HN deprives you of the ability to do that. 
  2899. And you do certainly talk about it with other people.
  2900.    
  2901. As I read HN, I have to figure things out each time I read them...
  2902.    
  2903.                                        Brian
  2904.  
  2905.  
  2906.  
  2907. #: 33850 S5/C++ Study Group            orig= 143 next=     prev= 144
  2908.     19-Aug-91  14:44:57                 No: 150 One Reply
  2909. Sb: #33773-Hungarian
  2910. Fm: Greg Comeau (ComeauComp) 72331,3421
  2911. To: Brian Richter 76437,736
  2912.    
  2913. >vbchrMac
  2914.    
  2915. Phew.  Even with the verbiage, I don't understand what the thing does.
  2916.    
  2917. I hope this example was significant enough to be demonstrative enough
  2918. to signify the end of HN!!! (and the end of the thread ;-})
  2919.  
  2920.  
  2921.  
  2922. #: 33875 S5/C++ Study Group            orig=PgUp next=     prev=
  2923.     19-Aug-91  17:51:24                 No: 151
  2924. Sb: #33850-Hungarian
  2925. Fm: Brian Richter 76437,736
  2926. To: Greg Comeau (ComeauComp) 72331,3421
  2927.    
  2928. vbchrMac...
  2929.    
  2930. Even with the code fragment in front of me, I don't understand what it does!
  2931.    
  2932. Even I, who started this thing, believe we've had plenty of discussion on this.
  2933. So I was in fact going to recommend we end this thing.  Except that I would
  2934. still be curious to see that thread with Petzold if anybody can retrieve it...
  2935.    
  2936. As a final note, I have nearly completed a Hungarianectomy on the program I'm
  2937. working on.  It's a sizable program but the process is easy (though a bit
  2938. tedious).  Seeing the identical code in HN and non-HN forms is an excellent
  2939. test.  And so far non-HN is winning (but of course you knew that would happen).
  2940. It's almost startling to see pieces of code that looked messy before suddenly
  2941. appear elegant and simple.
  2942.    
  2943. And BTW, thanks to all youse other guys who responded.  You have saved the
  2944. world from quite a few potential HN programs!
  2945.    
  2946.                                        Brian
  2947.  
  2948.  
  2949.  
  2950.